question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

standardize commandline patterns

See original GitHub issue

There are many ways to create grammars for command line programs. I will enumerate a few options using git as an example:

A) no new lines ever

git push: "git push "

B) new lines sometimes (perhaps when I use “git diff” I’m always comparing branches, never using it on its own for example)

git push: "git push\n"
git pull rebase: "git pull --rebase\n"
git move: "git mv "
git diff: "git diff"

C) new lines everywhere (except where it obviously doesn’t make sense)

git push: "git push\n"
git pull rebase: "git pull --rebase\n"
git move: "git mv "
git diff: "git diff\n"

and regarding text captures a similar design decision

X) no text captures anywhere

git commit message: "git commit -m '[|]'"
git check out: "git checkout "

Y) text captures on incantations which often get followed by additional text (perhaps I almost never use any additional arguments to “git pull”)

git commit message <user.optional_text>: "git commit -m '{optional_text}'"
git pull: "git pull"

Z) text captures anywhere free text it is valid

git add <user.optional_text>: "git add {user.optional_text}"
git push force <user.optional_text>: "git push --force {user.optional_text}"

Many of these patterns are applicable to lots of commandline programs. it would be nice to understand the trade-offs of different styles and select a single style and keep everything consistent and predictable. Perhaps there are additional styles I’m not including here, feel free to add to the list.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:17

github_iconTop GitHub Comments

4reactions
dwielcommented, Sep 18, 2020

A) no new lines ever

3reactions
dwielcommented, Sep 18, 2020

Z) text captures everywhere

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a "standard" format for command line/shell help text?
It is a formal standard for documenting (and automatically parsing) command line arguments. For example... Usage: my_program command --option <argument> ...
Read more >
4. Standardized command line options
To supply a list of such patterns, give +ffile with one pattern per line. To give a single pattern starting with +f, escape...
Read more >
Command-Line Processing with .NET Core 1.0 - Microsoft Learn
NET Core built-in library might help standardize, even if only a little, the command-line format/structure between programs. It isn't so important to me ......
Read more >
The Command Pattern in Depth - Oracle Blogs
Packaging commands as objects and sending them to a receiver enables a clean, loosely coupled design that's easy to maintain.
Read more >
The Sed Text Processor - Introduction to the Command Line
Instead of specifying patterns that can operate on any line, we can specify an exact line or range of lines to edit. $...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found