Giter Club home page Giter Club logo

Comments (13)

jcox250 avatar jcox250 commented on May 24, 2024 1

Sweet! I'll have a stab at it over the weekend

from mole.

davrodpin avatar davrodpin commented on May 24, 2024 1

@jcox250, please proceed with the implementation using pflag as you suggested before. We can think on redesigning the flags and how the user interacts with the tool later.

from mole.

jcox250 avatar jcox250 commented on May 24, 2024

Do you want to try and do this still using the stdlib flag package? Or would you be happy for a library like cobra to be used?

from mole.

davrodpin avatar davrodpin commented on May 24, 2024

Thanks for considering contributing to the project, @jcox250!

Cobra seems to be slick, I like that!

Moving to it will probably break the backwards compatibility, but will provide a robust and elegant way of handling the flags. We just need to make sure it's going to be very easy for the users to understand the commands and flags.

Please feel free to make the modifications and let me know where I can help.

from mole.

jcox250 avatar jcox250 commented on May 24, 2024

@davrodpin So I've had a go at this and think I've got something that should work. I've used spf13/pflag instead of cobra because it's API meant the code could pretty much stay the same and just use pflag in any place where the stdlib flag package was used.

One issue I've run into is short version of flag names aren't allowed to be longer than 1 character which rules out using st for start and also means that one of --version or --verbose can't use -v as a short flag.

Do you've any thoughts on what you would want the short version for these flags to be instead?

Also, just want to double check that when I put the PR up do you want me to check the spf13/pflag into the vendor directory?

from mole.

jcox250 avatar jcox250 commented on May 24, 2024

If it helps I opened a PR on my fork so you can have a look when deciding short names. Still need to add tests for the short names but I can do that after we get the short names sorted.
https://github.com/jcox250/mole/pull/1

from mole.

davrodpin avatar davrodpin commented on May 24, 2024

@jcox250, I saw value on using cobra because we would make all supported use cases to follow the <command> <args> pattern promoted by the library.
pflag seems to do almost what flag does, with the addition of a few helpers, so why not stick the the standard flag package, so no dependencies are added to the project?

from mole.

condemil avatar condemil commented on May 24, 2024

You can also check out go-flags, I am using it in my projects https://github.com/jessevdk/go-flags

from mole.

jcox250 avatar jcox250 commented on May 24, 2024

@davrodpin So the one advantage that you get from pflag that you don't get from flag is the ability to have short flag names which you can't get with flag. I could change it to use cobra instead though if you want? I just settled of pflag because I thought it would require less maintenance/changes to the code base.

from mole.

ricardoseriani avatar ricardoseriani commented on May 24, 2024

Since the PR of this is not already merged, can I try do add this and open a new PR ?

I'm thinking about using the github.com/spf13/pflag package.
If so, what will be the sort flag of the -start ? Because, as noted, short version of flag names aren't allowed to be longer than 1 character.

from mole.

davrodpin avatar davrodpin commented on May 24, 2024

Since the PR of this is not already merged, can I try do add this and open a new PR ?

That would be great, @ricardoseriani, thank you! Please take a look on #36 to understand previous design decisions.

I'm thinking about using the github.com/spf13/pflag package.

I see no problem with that.
Just as a mental note, I want to move the entire application to use something like cobra at some time in the future to have a better modularization of each workflow inside mole.

If so, what will be the sort flag of the -start ? Because, as noted, short version of flag names aren't allowed to be longer than 1 character.

I've updated the issue description with a new proposal for the short name for the flags

from mole.

ricardoseriani avatar ricardoseriani commented on May 24, 2024

For the usage, should I show both versions of flags ?

I'm thing about show the first lines using both flags (using | as separator) and the other lines show only the long flag, like this:

usage:
	mole [--verbose|-v] [--insecure|-i] [--detach|-x] (--local|-l [<host>]:<port>)... (--remote|-r [<host>]:<port>)... --server|-s [<user>@]<host>[:<port>] [--key|-k <key_path>] [--keep-alive-interval|-K <time_interval>] [--connection-retries|-R <retries>] [--retry-wait|-w <time>]
	mole --alias <alias_name> [--verbose] (--local [<host>]:<port>)... (--remote [<host>]:<port>)... --server [<user>@]<host>[:<port>] [--key <key_path>] [--keep-alive-interval <time_interval>] [--connection-retries <retries>] [--retry-wait <time>]
	mole --alias <alias_name> --delete
	mole --start <alias_name>
	mole --help
	mole --version

Or you think that I should add an example of using the short flags in another line (to avoid confusing new people) ?

from mole.

davrodpin avatar davrodpin commented on May 24, 2024

Let's keep the long names in the examples only. One will use the short names probably when they get used to the tool so we can consider it an "advanced" feature.

from mole.

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.