Coder Social home page Coder Social logo

argparse's People

Contributors

bakpakin avatar crocket avatar pepe avatar pyrmont avatar rduplain avatar subsetpark avatar uvtc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

argparse's Issues

Deprecate and redirect to spork/argparse

As the functionality of this package is also present in the spork package, I would consider deprecating it and redirect any future users to spork.

My only reason is not to have duplicate work if we find any bugs or improvements.

It's difficult to figure out how to handle unnamed arguments.

Although (doc argparse/argparse) says

There is also a special option :default that will be invoked on arguments that do not start with a -- or -. Use this option to collect unnamed arguments to your script.

I cannot figure out how to translate this explanation into code.

(argparse "..." :default)

doesn't really capture unnamed arguments.

argparse doesn't understand `--`.

This is my whenSafe script.

#!/usr/bin/env janet
(import argparse)

(let [{"script" scripts "pager" pager :default cmd-args}
      (argparse/argparse
        (string "If all scripts execute successfully, execute arguments.\n"
                "Usage: whenSafe -s script1 -s script2 -s ... -p pager "
                "cmd cmd-amrgs...")
        "script" {:kind :accumulate
                  :short "s"
                  :required true
                  :help (string "If its exit code is not zero, "
                                "its standard output is printed to pager.")}
        "pager" {:kind :option
                 :short "p"
                 :required true
                 :help "The pager used to notify errors."}
        :default {:kind :accumulate
                  :required true
                  :help "command to execute"})]
  (pp scripts)
  (pp pager)
  (pp cmd-args))

Execute ./whenSafe -s script1 -s script2 -p pager echo ok.

@["script1" "script2"]
"pager"
@["echo" "ok"]

Execute ./whenSafe -s script1 -s script2 -p pager -- echo -n ok.

usage error: unknown option
usage: ./whenSafe [option] ...

If all scripts execute successfully, execute arguments.
Usage: whenSafe -s script1 -s script2 -s ... -p pager cmd cmd-amrgs...

 Required:
 -p, --pager VALUE                           The pager used to notify errors.
 -s, --script VALUE                          If its exit code is not zero, its standard output is printed to pager.

 Optional:
 -h, --help                                  Show this help message.

error: expected string|symbol|keyword|array|tuple|table|struct|buffer, got nil
  in _thunk [./whenSafe] (tailcall) on line 4, column 1

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.