Skip to content

Commit

Permalink
Update usage message (#16)
Browse files Browse the repository at this point in the history
* docs: surround must-choose-one option group with braces

See also: https://docs.oracle.com/cd/E19455-01/806-2914/6jc3mhd5q/index.html

* docs: show options of match mode before graph mode

Because the match mode is the default mode.

* docs: update usage section
  • Loading branch information
Lai-YT authored Aug 2, 2023
1 parent fe97e3e commit 05d05a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ $ bin/regexp -h # or --help
```
regexp
Usage: regexp [-h] [-V] [-g regexp [-o FILE]] [[-c] regexp string]
Usage: regexp [-h] [-V] {-g regexp [-o FILE] | [-c] regexp string}
Description: Regular expression implementation.
Supports . ( ) | * + ?. No escapes.
Compiles to NFA and then simulates NFA using Thompson's algorithm.
One can either graph the regexp or match a string.
One can either match a string (default) or graph the regexp.
See the following options.
Notice that character # can't appear in the regular expression,
it's reserved technically as the special character.
Expand All @@ -90,6 +90,14 @@ Options:
-h, --help Shows this help message and exit
-V, --version Shows regexp version and exit
Match mode:
Matches the string with the regular expression,
exits with 1 if regexp is ill-formed or it does not match
-c, --cache Caches NFA states to build DFA on the fly
regexp The regular expression to use on matching
string The string to be matched
Graph mode:
Converts the regular expression into a graph,
exits with 1 if regexp is ill-formed or the file can't be opened
Expand All @@ -102,14 +110,6 @@ Graph mode:
(default: nfa)
regexp The regular expression to be converted
Match mode:
Matches the string with the regular expression,
exits with 1 if regexp is ill-formed or it does not match
-c, --cache Caches NFA states to build DFA on the fly
regexp The regular expression to use on matching
string The string to be matched
Written by: Lai-YT
regexp version: 1.0.2
Expand Down
6 changes: 3 additions & 3 deletions src/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void help() {
*/
void usage() {
fprintf(stdout, YELLOW "Usage: " NO_COLOR);
fprintf(stdout, "%s [-h] [-V] [-g regexp [-o FILE]] [[-c] regexp string]\n\n",
fprintf(stdout, "%s [-h] [-V] {-g regexp [-o FILE] | [-c] regexp string}\n\n",
PROGRAM_NAME);
}

Expand All @@ -44,7 +44,7 @@ void description() {
"Supports . ( ) | * + ?. No escapes.\n"
"Compiles to NFA and then simulates NFA using Thompson's algorithm.\n"
"\n"
"One can either graph the regexp or match a string.\n"
"One can either match a string (default) or graph the regexp.\n"
"See the following options.\n"
"Notice that character # can't appear in the regular expression,\n"
"it's reserved technically as the special character.\n"
Expand Down Expand Up @@ -91,8 +91,8 @@ void options() {
" -V, --version Shows %s version and exit\n"
"\n" NO_COLOR,
PROGRAM_NAME);
graph_mode();
match_mode();
graph_mode();
}

/*
Expand Down

0 comments on commit 05d05a8

Please sign in to comment.