Giter Club home page Giter Club logo

Comments (4)

epage avatar epage commented on June 20, 2024

An option based on #24

name: myapp
version: "1.0"
author: Kevin K. <[email protected]>
about: Does awesome things
args:
    - name: config
      short: c
      long: config
      value_name: FILE
      help: Sets a custom config file
      takes_value: true
    - name: INPUT
      help: Sets the input file to use
      required: true
      index: 1
    - app:
        help_heading: DEBUG
    - name: verbose
      short: v
      multiple: true
      help: Sets the level of verbosity
subcommands:
    - test:
        about: controls testing features
        version: "1.3"
        author: Someone E. <[email protected]>
        args:
            - debug:
                short: d
                help: print debug information

In effect, the data model for args is

struct App {
    ...
    args: Vec<ArgEntry>,
}

#[serde(untagged)]
enum ArgEntry {
    App(AppArg),
    Arg(Arg),
}

struct AppArg {
  app: AppArg2
}

struct AppArg2 {
    help_heading: Option<String>
}

(Ok, I got less creative with names as I went)

from clap-serde.

aobatact avatar aobatact commented on June 20, 2024

Is this clap-rs/clap#3002?

from clap-serde.

aobatact avatar aobatact commented on June 20, 2024

What is the difference between AppArg and Arg?

from clap-serde.

epage avatar epage commented on June 20, 2024

Parts are in clap-rs/clap#3002 and in other issues.

AppArg exists for forcing the app key to be present since ArgEntry needs to be untagged.

from clap-serde.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.