Skip to content

Commit

Permalink
Add note about new config.toml file into --help
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarnett committed Sep 12, 2024
1 parent 64c5c8e commit 615be27
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions gcalcli/argparsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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='@',
Expand Down

0 comments on commit 615be27

Please sign in to comment.