8000 Example for processing subcommands · Issue #237 · scopt/scopt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Example for processing subcommands #237

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
opendatakraken opened this issue Jan 25, 2019 · 1 comment
Open

Example for processing subcommands #237

opendatakraken opened this issue Jan 25, 2019 · 1 comment

Comments

@opendatakraken
Copy link
opendatakraken commented Jan 25, 2019

In this example commands are processed using config.mode:
https://www.spantree.net/blog/2017/06/26/scala-native-for-cli-tools.html

  parser.parse(args, Config()) match {
    case Some(config) =>
      config.mode match {
        case "choose" =>
          Picker.choose(config.objects, config.count).foreach(println)
        case "roll" =>
          println(Picker.roll(config.objects(0).toInt, config.objects(1).toInt))
      }

    case None =>
    // arguments are bad, error message will have been displayed
  }

However mode is not a method of Config.
Which is the correct way of processing .cmd subcommands? Almost all examples just show

// do something

A more complete example would be very helpful.

@opendatakraken
Copy link
Author

I understood how it works:

.action((_, c) => c.copy(mode = "update"))

So issue is closed for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0