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

Add usage to modify command #429

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

patdavid
Copy link

This commit adds the usage line from the manpage to the modify
command for quick reference when called without parameters:

$ timew modify
Usage: timew modify ( start | end ) <id> <date>
Must specify start|end command to modify. See 'timew help modify'.

This makes it faster than looking up the syntax in the manpage and
helps build faster memory of syntax for users.

This commit adds the usage line from the manpage to the modify
command for quick reference when called without parameters:

```
$ timew modify
Usage: timew modify ( start | end ) <id> <date>
Must specify start|end command to modify. See 'timew help modify'.
```

This makes it faster than looking up the syntax in the manpage and
helps build faster memory of syntax for users.

Signed-off-by: Pat David <[email protected]>
Copy link
Member

@lauft lauft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I have some suggestions for the error messages you may take into consideration...

@@ -59,7 +59,7 @@ int CmdModify (
}
else
{
throw format ("Must specify start|end command to modify. See 'timew help modify'.", words.at (0));
throw format ("Usage: timew modify ( start | end ) <id> <date>\nMust specify start|end command to modify. See 'timew help modify'.", words.at (0));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that here the format function does not use the words.at (0) parameter at all.
I think we should change this to something like

Unknown sub-command '{}'!
Usage: timew modify ( start | end ) <id> <date>
Please add the start/end sub-command to 'modify'. See 'timew help modify'.

In action:

$ timew modify strat @2
Unknown sub-command 'strat'!
Usage: timew modify ( start | end ) <id> <date>
Please add the start/end sub-command to 'modify'. See 'timew help modify'.

@@ -46,7 +46,7 @@ int CmdModify (

if (words.empty())
{
throw std::string ("Must specify start|end command to modify. See 'timew help modify'.");
throw std::string ("Usage: timew modify ( start | end ) <id> <date>\nMust specify start|end command to modify. See 'timew help modify'.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can also add some info what went wrong:

Missing sub-command!
Usage: timew modify ( start | end ) <id> <date>
Please add the start/end sub-command to 'modify'. See 'timew help modify'.

e.g.:

$ timew modify @4
Missing sub-command!
Usage: timew modify ( start | end ) <id> <date>
Please add the start/end sub-command to 'modify'. See 'timew help modify'.

@lauft lauft added the enhancement New feature or request label Jun 11, 2021
@lauft
Copy link
Member

lauft commented Jul 14, 2021

@patdavid Will there be any update from your side? Otherwise I would just merge your work with the suggested changes myself...

@patdavid
Copy link
Author

Ah, sorry - this slipped out of memory for me. :( (sorry!)

I don't have anything else to add at the moment, although I'm happy to revisit this when I can carve out a little more time and maybe propagate the idea to the rest of the commands for more helpful messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-branch enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants