Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure usages of ~ also use os.path.expanduser. #153

Merged
merged 1 commit into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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