Git Product home page Git Product logo

Comments (4)

xenomachina avatar xenomachina commented on May 29, 2024 1

I've been working on a change to add "subcommand" support (see #2 ). Do you think that would be sufficient for what you're trying to do?

The user-interface would look slightly different. Instead of:

program --config CONFIGFILE
program --version

it would be:

program config CONFIGFILE
program version

In general, the format is:

program [global options...] SUB-COMMAND-NAME [sub-command-specific options and arguments]

This is similar to (and is based on) tools like git where one top-level command (git) has multiple sub-commands (checkout, clone, push, reset, etc.) that take different options/arguments.

from kotlin-argparser.

davidschreiber avatar davidschreiber commented on May 29, 2024

Sub-command support seems like the cleaner approach than omission of required parameters. I would really love to see this, as right now most of my commands are optional (although at least one should be probably mandatory at any time).

from kotlin-argparser.

joffrey-bion avatar joffrey-bion commented on May 29, 2024

Sub-command support seems like the cleaner approach than omission of required parameters.

Subcommands are great, but I believe that it's not the right tool for the job here. Most programs don't work with subcommands and have instead some sort of "multiple usages" mindset, which I believe can be reasonably named the "anonymous subcommands" or "implicit subcommands" pattern.

I believe a lot of programs want usages like this:

Usage: program -h
Usage: program -v
Usage: program [standard args]

which corresponds to implicit "help", "version", and "default" subcommands.

There is actually one such implicit subcommand already implemented in kotlin-argparser: the help flag. It'd be nice to generalize this behaviour, maybe by using mutually exclusive option groups, that would act like anonymous subcommands.

A more simple implementation would be a special option type "standalone option" which would at least allow separating a single option from the rest, exactly like the help flag but for any custom option.

This feature would be very useful to implement for instance:

  • a version flag
  • a path to a configuration file that provides all mandatory arguments

from kotlin-argparser.

pcoltau avatar pcoltau commented on May 29, 2024

Regarding the version flag, then I've recently made this PR: #70

from kotlin-argparser.

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.