diff options
author | Andrés M <andmarti1424@users.noreply.github.com> | 2020-02-06 13:46:09 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-06 13:46:09 -0300 |
commit | 3ce04c7bc690d732a25b976b3737c809e2146c39 (patch) | |
tree | 9ee86b4d02f3df164ef942c7c87b9a4904a3fa1f /src | |
parent | eb809f9cb9ee0c9c868e41609c2e50865646e7d6 (diff) | |
parent | b1d8c78564a9686164952e9a13c7899772c983fe (diff) |
Merge pull request #384 from mipmip/pr-add-help-option
add --help option
Diffstat (limited to 'src')
-rw-r--r-- | src/conf.c | 1 | ||||
-rw-r--r-- | src/main.c | 54 | ||||
-rw-r--r-- | src/main.h | 1 |
3 files changed, 56 insertions, 0 deletions
@@ -80,6 +80,7 @@ void store_default_config_values() { put(user_conf_d, "ignorecase", "0"); put(user_conf_d, "trigger", "1"); put(user_conf_d, "version", "0"); + put(user_conf_d, "help", "0"); #ifdef AUTOBACKUP put(user_conf_d, "autobackup", "0"); // 0:noautobackup, n>0: backup every n in seconds #endif @@ -204,6 +204,10 @@ int main (int argc, char ** argv) { // Read the main() parameters and replace values in user_conf_d as necessary read_argv(argc, argv); + // check if help is in argv. if so, show usage and quit + if (atoi((char *) get_conf_value("help"))) // atoi converts string to an int + show_usage_and_quit(); + // check if version is in argv. if so, show version and quit if (atoi((char *) get_conf_value("version"))) // atoi converts string to an int show_version_and_quit(); @@ -801,3 +805,53 @@ void show_version_and_quit() { #endif put(user_conf_d, "quit_afterload", "1"); } + +/** + * \brief Print usage message to stdout text and quit + * + * \return none + */ + +// NOTE this is a quick and dirty command to search for arguments used in the sources (macOS 10.14) +// grep "get_conf_value(\"" -r ./src/*.c | grep get_conf_value |sed 's/"//g' |sed 's/.*get_conf_value(//g'|cut -d ')' -f1 |sort|uniq|sed 's/^/--/g' +void show_usage_and_quit(){ + put(user_conf_d, "nocurses", "1"); + printf("\ +\nSC-IM - SC Improved\ +\n\ +\nUsage: sc-im [arguments] [file] specified file\ +\n or: sc-im [arguments] - read text from stdin\ +\n\ +\nArguments:\ +\n\ +\n --autocalc Set variable 'autocalc'.\ +\n --copy_to_clipboard_delimited_tab Set variable 'copy_to_clipboard_delimited_tab'\ +\n --debug Set variable 'debug'\ +\n --default_copy_to_clipboard_cmd=COMMAND set variable 'default_copy_from_clipboard_cmd'\ +\n --default_paste_from_clipboard_cmd=COMMAND set variable 'default_paste_from_clipboard_cmd'\ +\n --export_csv Export to csv without interaction\ +\n --export_tab Export to tab without interaction\ +\n --export_txt Export to txt without interaction\ +\n --external_functions Set variable 'external_functions'\ +\n --half_page_scroll Set variable 'half_page_scroll'\ +\n --ignorecase Set variable 'ignorecase'\ +\n --import_delimited_as_text Import text as\ +\n --newline_action={j or l} Set variable 'newline_action'\ +\n --nocurses Run interactive but without ncurses interface.\ +\n --numeric Set variable 'numeric'\ +\n --numeric_decimal Set variable 'numeric_decimal'\ +\n --output=FILE Save the results in FILE\ +\n --overlap Set variable 'overlap variable'\ +\n --quit_afterload Quit after loading all the files\ +\n --sheet=SHEET Open SHEET when loading xlsx file. Default is 1.\ +\n --tm_gmtoff={seconds} set gmt offset used for converting datetimes to localtime.\ +\n --txtdelim={\",\" or \";\" or \"\\t\"} Sets delimiter when opening a .tab of .scv file"); +#ifdef XLSX + printf("\n\ +\n --xlsx_readformulas Set variable 'xlsx_readformulas'"); +#endif + printf("\n\ +\n --version Print version information and exit\ +\n --help Print Help (this message) and exit\n"); + put(user_conf_d, "quit_afterload", "1"); +} @@ -53,6 +53,7 @@ void setorder(int i); void nopipe(); void signals(); void show_version_and_quit(); +void show_usage_and_quit(); // SIGINT signal void sig_int(); |