From 29a13e28cdecb7c5175bb97d78374e5df2608e24 Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 3 Jan 2024 18:14:03 +0100 Subject: [PATCH] doc: improve usage output --- README.md | 21 ++++++++++----------- src/config.cr | 34 +++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 8e9e4bd..39ed8a7 100644 --- a/README.md +++ b/README.md @@ -74,17 +74,16 @@ make install Run Code-Preloader with the following command-line options: ``` -Usage: code-preloader [options] ROOT_DIR - -c CONFIG_FILE, --config=CONFIG_FILE - Load parameters from CONFIG_FILE - -i REGEX, --ignore=REGEX - Ignore file or directory matching REGEX - -o OUTPUT_FILE, --output=OUTPUT_FILE - Write output to OUTPUT_FILE - -H HEADER_PROMPT_FILE, --header-prompt=HEADER_PROMPT_FILE - Load header prompt from HEADER_PROMPT_FILE - -F FOOTER_PROMPT_FILE, --footer-prompt=FOOTER_PROMPT_FILE - Load footer prompt from FOOTER_PROMPT_FILE +CodePreloader v0.1.0 +Usage: code-preloader [options] DIR ... + +Options: + -c FILE, --config=FILE Load parameters from FILE + -i REGEXP, --ignore=REGEXP Ignore file or directory + -o FILE, --output=FILE Write output to FILE + -H FILE, --header-prompt=FILE Load header prompt from FILE + -F FILE, --footer-prompt=FILE Load footer prompt from FILE + --version Show version -h, --help Show this help ``` diff --git a/src/config.cr b/src/config.cr index d0c29c4..9a866f5 100644 --- a/src/config.cr +++ b/src/config.cr @@ -17,44 +17,48 @@ module CodePreloader def parse_arguments(args : Array(String)) OptionParser.parse(args) do |parser| - parser.banner = "Usage: code-preloader [options] DIR1 ..." + parser.banner = [ + "#{PROGRAM_NAME} v#{VERSION}", + "Usage: code-preloader [options] DIR ...\n", + "Options:" + ].join("\n") parser.on( - "-c CONFIG_FILE", - "--config=CONFIG_FILE", - "Load parameters from CONFIG_FILE" + "-c FILE", + "--config=FILE", + "Load parameters from FILE" ) do |config_file| load_config(config_file) end parser.on( - "-i IGNORE_PATH", - "--ignore=IGNORE_PATH", + "-i REGEXP", + "--ignore=REGEXP", "Ignore file or directory" ) do |ignore_file| @ignore_list << ignore_file end parser.on( - "-o OUTPUT_FILE", - "--output=OUTPUT_FILE", - "Write output to OUTPUT_FILE" + "-o FILE", + "--output=FILE", + "Write output to FILE" ) do |output_file| @output_file_path = output_file end parser.on( - "-H HEADER_PROMPT_FILE", - "--header-prompt=HEADER_PROMPT_FILE", - "Load header prompt from HEADER_PROMPT_FILE" + "-H FILE", + "--header-prompt=FILE", + "Load header prompt from FILE" ) do |header_prompt_file| @header_prompt_file_path = header_prompt_file end parser.on( - "-F FOOTER_PROMPT_FILE", - "--footer-prompt=FOOTER_PROMPT_FILE", - "Load footer prompt from FOOTER_PROMPT_FILE" + "-F FILE", + "--footer-prompt=FILE", + "Load footer prompt from FILE" ) do |footer_prompt_file| @footer_prompt_file_path = footer_prompt_file end