Skip to content
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 [OPTION] -flagA arg0 -flagB arg1 -flagC arg2 #1104

Closed
hnistlzy opened this issue Apr 12, 2020 · 5 comments
Closed

cli [OPTION] -flagA arg0 -flagB arg1 -flagC arg2 #1104

hnistlzy opened this issue Apr 12, 2020 · 5 comments
Assignees
Labels
area/v2 relates to / is being considered for v2 kind/question someone asking a question status/triage maintainers still need to look into this
Milestone

Comments

@hnistlzy
Copy link

How to achieve such a program just like “cli [OPTION] -flagA arg0 -flagB arg1 -flagC arg2”

@hnistlzy hnistlzy added area/v2 relates to / is being considered for v2 kind/question someone asking a question status/triage maintainers still need to look into this labels Apr 12, 2020
@rliebz
Copy link
Member

rliebz commented Apr 14, 2020

If [OPTION] is a positional argument, which covers arbitrary values that get passed in like a function parameter would be, the docs for usage are here: https://github.com/urfave/cli/blob/master/docs/v2/manual.md#arguments

If [OPTION] should be a command, which covers a fixed number of different actions that could be taken, the docs are here: https://github.com/urfave/cli/blob/master/docs/v2/manual.md#subcommands

If the question is about how to pass the same flags to every command, there's two options:

  1. Define a list of flags, then use them as configuration for each command:
flags := []cli.Flag{
    // ...
}
app := cli.NewApp()
app.Commands = []*cli.Command{
    {
        Name: "cmd1",
        Flags: flags,
        // ...
    },
    {
        Name: "cmd2",
        Flags: flags,
        // ...
    },
}
  1. Define them globally so they are available for all commands out of the box. If this option is picked, flags must be passed before the command rather than after, like so: cli -flagA arg0 -flagB arg1 -flagC arg2 [COMMAND]
app := cli.NewApp()
app.Flags = []cli.Flag{
    // ...
}

Let me know if that doesn't answer your question.

@igzzr
Copy link

igzzr commented Jun 10, 2020

thanks my bro

@stale
Copy link

stale bot commented Sep 9, 2020

This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else.

@stale stale bot added the status/stale stale due to the age of it's last update label Sep 9, 2020
@stale
Copy link

stale bot commented Oct 10, 2020

Closing this as it has become stale.

@stale stale bot closed this as completed Oct 10, 2020
@meatballhat meatballhat reopened this Apr 22, 2022
@meatballhat meatballhat removed the status/stale stale due to the age of it's last update label Apr 22, 2022
@meatballhat meatballhat added this to the Release 2.4.x milestone Apr 23, 2022
@meatballhat meatballhat self-assigned this Apr 24, 2022
@meatballhat
Copy link
Member

I think (?) this is resolved? @hnistlzy Please let us know if this should be reopened if that's not the case 😁

geofffranks pushed a commit to geofffranks/cli that referenced this issue Mar 21, 2024
When the wait flag is supplied to run-task, the cli will
not exit until the task enters a terminal state; SUCCEEDED or FAILED.

The cli exits 0 when the task succeeds and exits 1 when the task fails.

This improves the scriptability of tasks. They can be run
serially in a script.

Cherry-pick of 8671a5b (urfave#1861) to v8
Addresses Issue urfave#1104, #2238

Authored-by: Zach Robinson <zrobinson@pivotal.io>

Co-authored-by: Stephan Merker <merker.stephan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v2 relates to / is being considered for v2 kind/question someone asking a question status/triage maintainers still need to look into this
Projects
None yet
Development

No branches or pull requests

4 participants