Comments (13)
Sweet! I'll have a stab at it over the weekend
from mole.
@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.
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.
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.
@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.
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.
@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.
You can also check out go-flags, I am using it in my projects https://github.com/jessevdk/go-flags
from mole.
@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.
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.
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.
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.
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)
- Question on Usage: Define source as a non-existent hostname/domain name HOT 1
- logon using privatekey denied. error ssh: handshake failed: knownhosts: key is unknown HOT 1
- error runtime: bad pointer in frame github.com/konsorten/go-windows-terminal-sequences HOT 1
- Fix `add alias` help
- request for ENHANCEMENT: [github] xanzy/ssh-agent and/or passphrases for private keys ... HOT 3
- Feature request: unix socket forwarding
- Key mismatch HOT 8
- Missing `config` attribute on `<alias>.toml` file causing application to fail HOT 2
- New feature: SOCKS support
- ProxyCommand parameter in config not used, cannot use ssh proxy jump host HOT 1
- Can't get running configuration of detached instance HOT 1
- [Feature Request] Support aarch64 architecture for Raspberry Pi HOT 1
- [Feature Request] Support Remote Forwarding HOT 1
- [Feature Request] alias for remote port forwarding HOT 1
- Find another way to find is key is encrypted
- --detach not working HOT 8
- Mole not support ssh Include configuration files
- Show instances is not returning anything
- How to
- Ignoring IdentityAgent from SSH config and -A CLI option
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mole.