dtool icon indicating copy to clipboard operation
dtool copied to clipboard

Suggestion: flatter API

Open nicoburns opened this issue 5 years ago • 5 comments
trafficstars

I would love to be able to type:

echo "Hello World" | dtool snake_case
cat file.txt | dtool md5

This would make it much easier to remember the available commands.

For A2B style commands, it would be nice to have a long form available. For example

dtool hex to utf8

The short forms like h2s are probably good for typing quickly, but unfortunately it still ends up slower if I have to look up the command. I think I would be able to remember hex more easily than I am able to remember h.

nicoburns avatar Jan 07 '20 12:01 nicoburns

Thanks for your advice. Currently, the command line interface follows this pattern:

dtool <SUB_COMMAND> <FLAGS/OPTIONS> <INPUT>
  • <SUB_COMMAND> is alphanumeric without blank characters
  • < INPUT> is the last argument and can be replaced with standard input.

However, as you said, this pattern may be not ergonomic. I'm considering to provide shortcut or alias based on standard sub commands. e.g.

dtool md5 <INPUT>             =>    dtool hash -a md5 <INPUT>
dtool utf8 to hex <INPUT>     =>    dtool s2h <INPUT>

maybe I can make a mechanism to let users define their own shortcut or alias in a config file.

guoxbin avatar Jan 07 '20 15:01 guoxbin

Maybe using a single hyphen (-) as <INPUT> could tell dtool to read from stdin. I’ve seen this convention multiple times, most notably in Vim: echo 'Hello, World!' | vim -.

lunacookies avatar Jan 07 '20 23:01 lunacookies

Maybe using a single hyphen (-) as <INPUT> could tell dtool to read from stdin. I’ve seen this convention multiple times, most notably in Vim: echo 'Hello, World!' | vim -.

Now dtool read from stdin if no <INPUT> provided

guoxbin avatar Jan 08 '20 02:01 guoxbin

Considering add shortcut or alias

guoxbin avatar Jan 08 '20 02:01 guoxbin

Likewise, I would love to be able to use a filename as input, instead of piping.

For example: dtool hash -a sha3_256

dsully avatar Feb 23 '20 04:02 dsully