guumaster / hostctl

Your dev tool to manage /etc/hosts like a pro!
http://guumaster.github.io/hostctl
MIT License
1.05k stars 45 forks source link

New features #22

Closed guumaster closed 4 years ago

guumaster commented 4 years ago

Thinks I'd like to add:

Also with a --watch flag to monitor and react to changes

BarbUk commented 4 years ago

A common use-case is to add a command like:

hostctl init --shell [bash | zsh | fish | ...]

This command can be eval from the user shell dotfile and output the completion for the selected shell.

To have the profile / domains completion, a --batch flag to the list command can list available values:

# hostctl list --batch --column profile
default
site1
site2
# hostctl list --batch --column ip
192.168.10.10
192.168.10.11
guumaster commented 4 years ago

I like that about autocomplete and show columns.

Not sure I understand the --batch flag

BarbUk commented 4 years ago

Like mysql:

--batch, -B Print results using tab as the column separator, with each row on a new line

It would be used to remove the decoration of the output.

# mysql -e 'show processlist;'
+--------+------------------+-----------------+-------------------+--------------+------+-----------------------------------------------------------------------------+------------------+-------+
| 920843 | system user      |                 | NULL              | Slave_SQL    | 4483 | Slave has read all relay log; waiting for the slave I/O thread to update it | NULL             | 0.000 |
| 921883 | root             | localhost       | NULL              | Query        |    0 | init                                                                        | show processlist | 0.000 |
+--------+------------------+-----------------+-------------------+--------------+------+-----------------------------------------------------------------------------+------------------+-------+
# mysql --batch -e 'show processlist;'

920843  system user     NULL    Slave_SQL   4494    Slave has read all relay log; waiting for the slave I/O thread to update it NULL    0.000
921884  root    localhost   NULL    Query   0   init    show processlist    0.000
guumaster commented 4 years ago

Oh I see, I'm not sure if batch is the best name, but the feature may be useful.

I think we can do two things for this, one is a flag like --output clean (as opposed to the table default) and then a preference file (like $HOME/.hostctl/config`) where you can set different defaults options.

BarbUk commented 4 years ago

I think we can do two things for this, one is a flag like --output clean

or --output raw

The use case for the output without a table decoration is:

So I don't know if a preference in a config file is needed for that.

Cobra seem to provide ressources to generate completion, there is some documentation available here: https://github.com/spf13/cobra/blob/master/bash_completions.md

guumaster commented 4 years ago

@BarbUk I've implemented --raw output and --column selection, but after reading the guides on autocompletion for cobra I cannot make it work. If you want to give it a try, there is an open branch/PR #28 that you can start from

guumaster commented 4 years ago

Moving this list to #45