Code Monkey home page Code Monkey logo

climax's People

Contributors

ma124 avatar sahib avatar tucnak 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

climax's Issues

If I try to use a flag in CLI that is not defined, gets a panic

If try tu run a small minimal app with climax, that doesn't have 't' flag defined, I get a panic:

 # ./stellar-stacy serve -t=3
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x40 pc=0x4814b6]

goroutine 1 [running]:
github.com/tucnak/climax.parseContext(0xc8200a0410, 0x1, 0x1, 0xc82007e260, 0x1, 0x1, 0x1, 0x0, 0x0)
    /home/foo/go/src/github.com/tucnak/climax/context.go:97 +0x496
github.com/tucnak/climax.Application.Run(0x78c890, 0x6, 0x7c1b80, 0x10, 0x821350, 0x13, 0xc8200ba180, 0x1, 0x1, 0x0, ...)
    /home/foo/go/src/github.com/tucnak/climax/application.go:117 +0xa19
main.main()
    /home/foo/go/src/myserver/myroot/stellar-stacy/main.go:21 +0x173

When launching it with a flag that exists, it works fine. The climax.Command structure I used is the one defined on the main github page.

Lightweight command syntax

We need a super lightweight syntax of creating simple flag-less commands. Something like this would be great:

app := climax.New("appname")

app.Comm("command", "i am command", func (ctx climax.Context) {
    return 0;
});

Iterators?

I am using this library in my application at https://github.com/parallelcointeam/pod - because it seems to be the most friendly and accessible CLI flags library that exists for Go. However, my application needs some 40-50 separate parameters in most instances of the use of climax and I used a function wrapper to condense the declarations, but the ctx.Is and ctx.Get functions chew up a whole if block per parameter.

I am looking at it, and for the reason that the function that reads off the values from the command line to overlay the configuration struct for the subcommands, I looked closer at the source and noted that the variable and non-variable types have exported names and thus can be iterated.

Of course it is not (that) difficult to write this, but I'm just posting this issue to suggest that it could have an iterator built into it if one defined a map type that contains the pointers to the variables, in the case of variables, and for the nonvariable case, could produce an array containing the handlers associated with the nonvariable flags to enable order sensitivity to the triggers so in the case of a subcommand that terminates, that it can do this from one map literal declaration and the iterator command, and automatically executes it.

I am immediately in the process of refactoring my code's use of this by using an iterator on these maps, I would think that probably the function could be quickly modified to become generic, using a map[string]interface{}, enable the automatic determination of intended variable type, assignment and resolution of the interface to direct explicit type. I am using JSON as the configuration file format also, so I can constrain the types to match JSON in as much as objects go to maps and arrays to slices, then bool, int, float and string.

If there is interest in having a PR for adding this iterator, let me know, and I probably can create an additional source file to go with the library that implements this.

Do you support subcommands?

I thought that groups would be subcommands, but it seems they are only for grouping them on the help page. Does climax currently support subcommands? If so, how?

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.