-
Notifications
You must be signed in to change notification settings - Fork 563
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
CLI: simplify and clarify usage text #7277
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,29 +16,15 @@ var outputPath string | |
var jsonOutput bool | ||
|
||
var callCmd = &FuncCommand{ | ||
Name: "call [options]", | ||
Short: "Call a module function", | ||
Long: strings.ReplaceAll(`Call a module function and print the result. | ||
|
||
If the last argument is either a Container, Directory, or File, the pipeline | ||
will be evaluated (the result of calling ´sync´) without presenting any output. | ||
Providing the ´--output´ option (shorthand: ´-o´) is equivalent to calling | ||
´export´ instead. To print a property of these core objects, continue chaining | ||
by appending it to the end of the command (for example, ´stdout´, ´entries´, or | ||
´contents´). | ||
`, | ||
Name: "call [options] [FUNCTION [FUNCTION...]]", | ||
Short: "Call a function, or a pipeline of functions", | ||
Long: strings.ReplaceAll(`Call a function, or a pipeline of functions, and print the result`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
"´", | ||
"`", | ||
), | ||
Example: strings.TrimSpace(` | ||
dagger call test | ||
dagger call build -o ./bin/myapp | ||
dagger call lint stdout | ||
`, | ||
), | ||
Init: func(cmd *cobra.Command) { | ||
cmd.PersistentFlags().BoolVar(&jsonOutput, "json", false, "Present result as JSON") | ||
cmd.PersistentFlags().StringVarP(&outputPath, "output", "o", "", "Path in the host to save the result to") | ||
cmd.PersistentFlags().StringVarP(&outputPath, "output", "o", "", "Save the result to a local file or directory.") | ||
}, | ||
OnSelectObjectLeaf: func(c *FuncCommand, name string) error { | ||
switch name { | ||
|
@@ -55,6 +41,7 @@ dagger call lint stdout | |
case Terminal: | ||
c.Select("websocketEndpoint") | ||
default: | ||
// FIXME: don't make this an error, it's confusing to users | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This error has been replaced with: Basically any chain that ends in an object that has itself functions, lists them under "Available Functions". |
||
return fmt.Errorf("return type %q requires a sub-command", name) | ||
helderco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[arguments]
and<function>
are appended to the usage line dynamically based on the existence of arguments or further functions, respectively. So this will produce the following:[options]
only show oncall
(doesn't include global flags), so leaving as is creates this usage while you keep adding functions (assuming there's constructor arguments):Notice also that we conventionalized usage syntax here:
<command>
in cmd.Use #7143