Skip to content

Commit

Permalink
Ensure usages of ~ also use os.path.expanduser. (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjprescott committed May 22, 2019
1 parent 7993fa2 commit 4acec27
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ We recommend specifying `cli_name`, `config_dir` and `config_env_var_prefix`.

For example:
`cli_name` - Name of CLI. Typically the executable name.
`config_dir` - Path to config dir. e.g. `os.path.join('~', '.myconfig')`
`config_dir` - Path to config dir. e.g. `os.path.expanduser(os.path.join('~', '.myconfig'))`
`config_env_var_prefix` - A prefix for environment variables used in config e.g. `CLI_`.

Use the `invoke()` method to invoke commands.
Expand Down
2 changes: 1 addition & 1 deletion examples/exapp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class MyCommandsLoader(CLICommandsLoader):


mycli = CLI(cli_name=cli_name,
config_dir=os.path.join('~', '.{}'.format(cli_name)),
config_dir=os.path.expanduser(os.path.join('~', '.{}'.format(cli_name))),
config_env_var_prefix=cli_name,
commands_loader_cls=MyCommandsLoader,
help_cls=MyCLIHelp)
Expand Down
2 changes: 1 addition & 1 deletion examples/exapp2
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class MyCLI(CLI):


mycli = MyCLI(cli_name=cli_name,
config_dir=os.path.join('~', '.{}'.format(cli_name)),
config_dir=os.path.expanduser(os.path.join('~', '.{}'.format(cli_name))),
config_env_var_prefix=cli_name,
commands_loader_cls=MyCommandsLoader,
help_cls=MyCLIHelp)
Expand Down
2 changes: 1 addition & 1 deletion examples/test_exapp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MyCommandsLoader(CLICommandsLoader):
name = 'exapp4'

mycli = CLI(cli_name=name,
config_dir=os.path.join('~', '.{}'.format(name)),
config_dir=os.path.expanduser(os.path.join('~', '.{}'.format(name))),
config_env_var_prefix=name,
commands_loader_cls=MyCommandsLoader)

Expand Down
2 changes: 1 addition & 1 deletion knack/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CLIConfig(object):
'0': False, 'no': False, 'false': False, 'off': False}

_DEFAULT_CONFIG_ENV_VAR_PREFIX = 'CLI'
_DEFAULT_CONFIG_DIR = os.path.join('~', '.{}'.format('cli'))
_DEFAULT_CONFIG_DIR = os.path.expanduser(os.path.join('~', '.{}'.format('cli')))
_DEFAULT_CONFIG_FILE_NAME = 'config'
_CONFIG_DEFAULTS_SECTION = 'defaults'

Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def load_command_table(self, args):
self.command_table['abc list'] = CLICommand(self.cli_ctx, 'abc list', a_test_command_handler)
return OrderedDict(self.command_table)

mycli = CLI(cli_name='exapp1', config_dir=os.path.join('~', '.exapp1'), commands_loader_cls=MyCommandsLoader)
mycli = CLI(cli_name='exapp1', config_dir=os.path.expanduser(os.path.join('~', '.exapp1')), commands_loader_cls=MyCommandsLoader)

expected_output = """[
{
Expand Down

0 comments on commit 4acec27

Please sign in to comment.