Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profiles as default argument in commands #37

Closed
smhmd opened this issue Apr 8, 2020 · 3 comments · Fixed by #48
Closed

Profiles as default argument in commands #37

smhmd opened this issue Apr 8, 2020 · 3 comments · Fixed by #48
Assignees
Labels
discussion Discussion about features or development
Milestone

Comments

@smhmd
Copy link
Contributor

smhmd commented Apr 8, 2020

Why not just have profiles the default argument in commands?
Instead of hostctl toggle -p awesome you'd have hostctl toggle awesome? (with -p still working for backward compatibility)

I get that the add command, for instance, can be convoluted and a flag (-p) to clearly define profile name is a healthy pattern. But profile as a default argument is straightforward for most other commands.

image

What do you think?

@smhmd smhmd added the feature New feature or request label Apr 8, 2020
@guumaster
Copy link
Owner

To maintain compatibility with all other commands, you need to use --profile,-p. But this is something I'm thinking on changing at some point, not sure.

@smhmd
Copy link
Contributor Author

smhmd commented Apr 8, 2020

profiles are First-class citizen in hostctl. It only makes sense to not require a flag to enter them in the first place.

add domains could be a flag itself: add --domain,-d, since it doesn't have any special flags or behavior from the add command, making profile default argument.

~ hostctl add -h
Reads from a file and set content to a profile in your hosts file.
If the profile already exists it will be added to it.

Usage:
  hostctl add [profile] [flags]

Flags:
  -f, --from string        file to read
  -h, --help                   help for add
      --host-file string   Hosts file path (default "/etc/hosts")
  -d, --domain string   Append content to your host file or profile
  -q, --quiet                   Run command without output
ex: hostctl add awesome -d test.loc another.loc --ip 123.123.123.123

@guumaster
Copy link
Owner

For now I think that for commands that make sense I could support both options:

hostctl toggle awesome == hostctl toggle -p awesome

When I'm done with all features that I have in mind, I'll think on this breaking change. I think it makes total sense, but it requires to change semantics on almost all commands.

@guumaster guumaster added discussion Discussion about features or development and removed feature New feature or request labels Apr 9, 2020
@guumaster guumaster mentioned this issue Apr 10, 2020
5 tasks
@guumaster guumaster added this to the v1.0.0 milestone Apr 10, 2020
@guumaster guumaster mentioned this issue Apr 13, 2020
5 tasks
guumaster added a commit that referenced this issue Apr 13, 2020
big module refactor, with 95 new tests! 🎉

* [x] Add a decent amount code coverage of all files in `pkg` directory.
* [x] Refactor `pkg` code to expose a better API to use as module.
* [x] Change semantics to have profiles as arguments instead of flag. #37
* [x] Allow to manage multiple profiles at once. Ex: `hostctl disable profile1 profile2... `
* [x] Add mutex to save file to avoid concurrency issues.

Fixes #37
Fixes #39
Closes #47
Related to #45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion about features or development
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants