-
Notifications
You must be signed in to change notification settings - Fork 124
User expansion #352
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
Merged
Merged
User expansion #352
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
05d2d2b
Allowing the use of ~user expansion in paths
kmvanbrunt c66d028
Added some basic user completion on Windows
kmvanbrunt ea5c242
Fixed unbound local warning
kmvanbrunt 26a5f4d
Added better check for whether a path is a directory
kmvanbrunt ff63a70
Trying to fix Windows unit test when running on AppVeyor
kmvanbrunt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -341,25 +341,19 @@ def test_path_completion_doesnt_match_wildcards(cmd2_app, request): | |
| # Currently path completion doesn't accept wildcards, so will always return empty results | ||
| assert cmd2_app.path_complete(text, line, begidx, endidx) == [] | ||
|
|
||
| def test_path_completion_invalid_syntax(cmd2_app): | ||
| # Test a missing separator between a ~ and path | ||
| text = '~Desktop' | ||
| line = 'shell fake {}'.format(text) | ||
| endidx = len(line) | ||
| begidx = endidx - len(text) | ||
|
|
||
| assert cmd2_app.path_complete(text, line, begidx, endidx) == [] | ||
| def test_path_completion_expand_user_dir(cmd2_app): | ||
| # Get the current user. We can't use getpass.getuser() since | ||
| # that doesn't work when running these tests on Windows in AppVeyor. | ||
| user = os.path.basename(os.path.expanduser('~')) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming the unit test all pass, this looks OK. They still pass on my system. |
||
|
|
||
| def test_path_completion_just_tilde(cmd2_app): | ||
| # Run path with just a tilde | ||
| text = '~' | ||
| text = '~{}'.format(user) | ||
| line = 'shell fake {}'.format(text) | ||
| endidx = len(line) | ||
| begidx = endidx - len(text) | ||
| completions_tilde = cmd2_app.path_complete(text, line, begidx, endidx) | ||
| completions = cmd2_app.path_complete(text, line, begidx, endidx) | ||
|
|
||
| # Path complete should complete the tilde with a slash | ||
| assert completions_tilde == [text + os.path.sep] | ||
| expected = text + os.path.sep | ||
| assert expected in completions | ||
|
|
||
| def test_path_completion_user_expansion(cmd2_app): | ||
| # Run path with a tilde and a slash | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice comments throughout