-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print one-liner description in usage if no block description
Still need to revisit this whole 'one liner' and 'block description' split, but right now, if you specify e.g. --- some description --- in a script, then this description doesn't get printed at all because it gets put into the 'one liner' field, and we leave the block empty, but in our usage logic, we only look at the block currently. In this commit, we fall back to the one-liner if it's there and the block description is not.
- Loading branch information
Showing
3 changed files
with
76 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package testing | ||
|
||
import "testing" | ||
|
||
func Test_FileHeader_PrintsOneLinerIfOnlyThat(t *testing.T) { | ||
rsl := ` | ||
--- | ||
This is a one liner! | ||
--- | ||
args: | ||
name string | ||
` | ||
setupAndRunCode(t, rsl, "-h", "--NO-COLOR") | ||
expected := `This is a one liner! | ||
Usage: | ||
test <name> | ||
Script args: | ||
--name string | ||
` + globalFlagHelp | ||
assertOnlyOutput(t, stdErrBuffer, expected) | ||
assertNoErrors(t) | ||
resetTestState() | ||
} | ||
|
||
func Test_FileHeader_PrintsExtra(t *testing.T) { | ||
rsl := ` | ||
--- | ||
This is a one liner! | ||
Here is | ||
the rest! | ||
--- | ||
args: | ||
name string | ||
` | ||
setupAndRunCode(t, rsl, "-h", "--NO-COLOR") | ||
expected := `Here is | ||
the rest! | ||
Usage: | ||
test <name> | ||
Script args: | ||
--name string | ||
` + globalFlagHelp | ||
assertOnlyOutput(t, stdErrBuffer, expected) | ||
assertNoErrors(t) | ||
resetTestState() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters