Coder Social home page Coder Social logo

clist's People

Contributors

apoigne avatar backuitist avatar havrikov avatar l15k4 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

clist's Issues

Colours do not work on windows 10 cmd console

Running the program from a Windows 10 console would output strange characters, which presumably correspond to the ANSI colours. The output displays things like �[4m and �[33m and �[24m etc.

It seems that windows 10 does not handle these well, and there were some breaking changes done in a recent update.

microsoft/WSL#1173

There was also some discussion related to this here:
scala/scala#5663

The simplest option could be to first add an option to disable coloured output.

If there is a way to detect whether the terminal supports colour one could use it to turn coloured output on, but I suspect it is not that trivial. (I would still leave the option to turn it off explicitly anyway for those who do not want colours.)

Parse error description is not too informative

Currently parse errors are shown as:
Unknown command 'Y1'
It will be nice to add context : what command, arguments were found, show input command string with the error position. Why this state is treated as error

Fail to parse multiple arg / require automatically prioritizing of Mandatory CliArg.

Commands
   push [<address>] <file> : publish a file and wait for pulling from client

In scenario showed above, push /path/file failed with:

Failed to parse command push: No argument provided for file

where [<address>] is an optional arg.

CliMandatoryArgument in newCtx could be prioritized? Below: args in newCtx have been consumed.

newCtx.firstArg match {
    case None =>
      sCmdArg match {
        case _: CliMandatoryArgument[_] =>
          throw ParsingException(ansi"No argument provided for %bold{${cmdArg.name}}")
        case optArg: CliOptionalArgument[_] =>
          setVar(cmdArg, optArg.default)
      }

    case Some(arg) =>
      readAndSetVar(sCmdArg, arg)
      newCtx = newCtx.validate(sCmdArg, arg)
}

Need to improve parsing of command line to work properly with quotes

In doc it is told:
Note that on the command line there is a distinction between
cat file1 file2 "file with space"
and
cat file1 file2 file with space

For clist parser there is no difference between this 2 lines. Currently it is impossible to send optional arguments values with space inside - this is a very hard limitation.
We can use standard shell line string grouping - we get Seq[String] - match each String in the Seq against template:
--option_name=*
Take * as the value for option. This way if we will set: --a="x y z" - we will properly define a = "x y z"
Current implementation will set --a=x y z - treat y,z - as arguments.

Arguments from environment or command line

If foo-bar argument is required and is found in environment as FOO_BAR then that should be used. If it is passed as command line argument then it should override the environment.

Parser does not seem to work properly for repeated args

I want to have possibly same args, e.g. "localhost 9090 localhost 9091" for a source and a target, each one read using a "arg" variable. Parser claims that the target host is missing in the example. Experiments let draw the conclusion that all args must be different.

Wildcard import shadows usual scala globals

The docs (README.md) recommend import org.backuity.clist._, which is concise, certainly, but there exists org.backuity.clist.Console, which breaks my existing calls to scala.Console such as Console.err.println("Exiting due to Ctrl-C"), etc.

I'm not a big fan of leading with wildcard imports, particularly in introductory documentation, but I know that everybody does it. But I think if you're going to recommend that approach, you might want to avoid shadowing anything in Scala's default imports?

Otherwise, import org.backuity.clist.{Cli, Command, opt} seems to be working just great!

args do not show description

Cannot see description for args in the command line help.
It will be nice to add rows with args names + description (may be with different from opt description color) - similar to opt description.

Dash-separated format for arguments

Looks like dash-separated format does not work for arguments. E.g:

var sourceCluster = arg[String]()

leads to:

No option found for --source-cluster=foo

It works fine if the argument is passed as --sourceCluster=foo

Command name can be specified after optional parameter definition

Program works in the same way independent of command_name position
Equal commands:
executable command_name --debug
executable --debug command_name

It will be nice to fix command_name to the first position (can have potential problem of mixing command and args). Information about global options is lost
cmd.read(globalOptions ::: params)

Support for numeric values

It is not clear if this API supports numeric (integers and floating points) values. One often needs to pass a specific numeric parameters. For example: --max-delay 3000 --max-error 3.24

It also needs to provide support for default values, for when they are omitted and a sensible default needs to be used in that case.

(If this functionality is actually supported the documentation doesn't show how to do this, so needs to be updated).

Some error for the Cat example

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodError: scala.runtime.ObjectRef.create(Ljava/lang/Object;)Lscala/runtime/ObjectRef;
at org.backuity.clist.Command.read(Command.scala:12)
at org.backuity.clist.Parser$$anonfun$withCommand$1.apply(Parser.scala:130)
at org.backuity.clist.Parser$$anonfun$withCommand$1.apply(Parser.scala:129)
at org.backuity.clist.Parser.withParsingException(Parser.scala:167)
at org.backuity.clist.Parser.withCommand(Parser.scala:129)
at com.xxx.CatDemo$.main(Pig.scala:16)
at com.xxx.CatDemo.main(Pig.scala)
... 6 more

<properties>
    <scala.version>2.11.8</scala.version>
</properties>

<dependency>
  <groupId>org.backuity.clist</groupId>
  <artifactId>clist-core_2.11</artifactId>
  <version>2.0.2</version>
</dependency>

<dependency>
  <groupId>org.backuity.clist</groupId>
  <artifactId>clist-macros_2.11</artifactId>
  <version>2.0.2</version>
</dependency>

Not clear how to handle required parameters

Parsing gives error if default value is not given:

java.lang.IllegalArgumentException: Incorrect argument 'foo': an optional argument that has neither type Option nor Boolean must have a default value

It is not immediately clear why required parameter must have a default value. Setting default value for a required parameter and then asserting passed value != default value looks like an awkward workaround.

Shouldn't the library say e.g. 'Missing required parameter' and optionally show help page instead of throwing this exception?

opt[Double] is not providing type description

I like idea of the module very much, got couple of problems working with it:
Help for program generates parameter description of the form:
--output=STRING : Save results to the file
--start : Starting x value [0]
For opsDouble - it is not printing type name

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.