From 615be277bbb2f2fa9c6bdaf0888d85a74cdab05a Mon Sep 17 00:00:00 2001 From: David Barnett Date: Wed, 11 Sep 2024 22:17:21 -0600 Subject: [PATCH] Add note about new config.toml file into --help --- gcalcli/argparsers.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/gcalcli/argparsers.py b/gcalcli/argparsers.py index e60a910..84e7b9e 100644 --- a/gcalcli/argparsers.py +++ b/gcalcli/argparsers.py @@ -293,12 +293,18 @@ class RawDescArgDefaultsHelpFormatter( %(prog)s supports a few other configuration mechanisms in addition to the command-line arguments listed below. - $GCALCLI_CONFIG={config_dir!r} + $GCALCLI_CONFIG={config_dir} Path to user config directory. Note: this path is also used to determine fallback paths to check for cache/oauth files to be migrated into their proper data dir paths. + {config_file} + A toml config file where some general-purpose settings can be + configured. + Schema: + https://raw.githubusercontent.com/insanum/gcalcli/HEAD/data/config-schema.json + gcalclirc @ {rc_paths} A flag file listing additional command-line args to always pass, one per line. @@ -311,14 +317,26 @@ class RawDescArgDefaultsHelpFormatter( @parser_allow_deprecated(name='program') def get_argument_parser(): config_dir = env.default_config_dir() - rc_paths = [pathlib.Path(config_dir).joinpath('gcalclirc')] + # Shorten path to ~/PATH if possible for easier readability. + tilde_home = pathlib.Path('~') + try: + tilde_relative = config_dir.relative_to( + tilde_home.expanduser(), walk_up=False) + config_dir = tilde_home.joinpath(tilde_relative) + except ValueError: + pass + rc_paths = [config_dir.joinpath('gcalclirc')] legacy_rc_path = pathlib.Path.home().joinpath('.gcalclirc') if legacy_rc_path.exists(): - rc_paths.append(legacy_rc_path) + rc_paths.append(tilde_home.joinpath('.gcalclirc') + if tilde_home.expanduser() == pathlib.Path.home() + else legacy_rc_path) parser = argparse.ArgumentParser( description=DESCRIPTION.format( - config_dir=config_dir, rc_paths=', '.join(str(p) for p in rc_paths) + config_dir=config_dir, + config_file=config_dir.joinpath('config.toml'), + rc_paths=', '.join(str(p) for p in rc_paths) ), formatter_class=RawDescArgDefaultsHelpFormatter, fromfile_prefix_chars='@',