-
Notifications
You must be signed in to change notification settings - Fork 18.4k
cmd/go: support -help
#75204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
+94
−1
Open
cmd/go: support -help
#75204
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
62 changes: 62 additions & 0 deletions
src/cmd/go/testdata/script/help_flag.txt
This file contains hidden or 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,62 @@ | ||
# Test that -help flag works for go commands | ||
|
||
# go -help shows main help (not an error) | ||
go -help | ||
stdout 'Go is a tool for managing Go source code' | ||
stdout 'Usage:' | ||
stdout 'go <command> \[arguments\]' | ||
|
||
# go build -help shows full help | ||
go build -help | ||
stdout 'usage: go build' | ||
stdout 'Build compiles the packages' | ||
stdout 'For more about specifying packages' | ||
|
||
# go install -help shows full help | ||
go install -help | ||
stdout 'usage: go install' | ||
stdout 'Install compiles and installs' | ||
stdout 'For more about specifying packages' | ||
|
||
# go get -help shows full help | ||
go get -help | ||
stdout 'usage: go get' | ||
stdout 'Get resolves its command-line arguments' | ||
stdout 'See also: go build, go install' | ||
|
||
# go fmt -help shows full help | ||
go fmt -help | ||
stdout 'usage: go fmt' | ||
stdout 'Fmt runs the command' | ||
stdout 'See also: go fix, go vet' | ||
|
||
# go run -help shows full help | ||
go run -help | ||
stdout 'usage: go run' | ||
stdout 'Run compiles and runs' | ||
stdout 'See also: go build' | ||
|
||
# go run program.go -help should pass -help to the program, not show go run help | ||
go run helpprog.go -help | ||
stdout 'Program help message' | ||
stdout 'Arguments: \[.*helpprog.*-help\]' | ||
|
||
-- helpprog.go -- | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func main() { | ||
var help = flag.Bool("help", false, "show help") | ||
flag.Parse() | ||
|
||
fmt.Printf("Arguments: %v\n", os.Args) | ||
|
||
if *help { | ||
fmt.Println("Program help message") | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.