Commit graph

216 commits

Author SHA1 Message Date
Oliver Bestwalter
7a04133611
implement vox create --prompt (#4676)
Pass the prompt arg through to venv.
Additionally, upgrade needs to be adjusted to keep a prompt setting if it is there.
2022-02-21 14:51:31 +05:30
Noortheen Raja
78091a22f3 style: isort imports
fix #4584
2022-01-31 11:16:51 -05:00
Noorhteen Raja NJ
e76115676b
improve completers (#4648)
* fix: pip -r appends spaces at the end

modularize completing output from subproc-out

* docs:

* fix: flake8

* fix: failing pip comp tests

* refactor: naming xonsh conflicts with actual package

the IDE completions don't work.
we add this naming convention instead.

* feat: option to filter after completion returned

this will help reduce some boilerplate, and we can enrich the filtering
behaviour

* feat: add gh completions

* fix: filtering out completions

* refactor: simplify invoking completer interface

* test: add fixture for xsh with os-env

* test: add tests for gh-completions

* fix: flake error

* fix: mypy errors and update gh completer tests

* fix: handle cross-platform line endings

* feat: include man,bash completer only if available

* todo: improve man page completions

* fix: failing man page tests

* fix: py 3.7 compatibility

* fix: qa error

* fix: stop dir completions

* feat: improve man page completions

now shows descriptions, recognizes more number of options correctly

* fix: update man page completions

* feat: support filtering based on display as well

* Update xonsh/completer.py

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>

* style:

* test: xfail ptk-shell tests on windows

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2022-01-27 21:22:36 +05:30
Noorhteen Raja NJ
a00b6014fe
chore: type check xontribs,xompletions (#4642)
as well as match dmypy semantics
2022-01-18 09:54:31 -05:00
Noorhteen Raja NJ
b76d6f994f
refactor: break multi-line question (#4621)
ignore error in fish completions
2022-01-15 14:44:46 +05:30
Hierosme
343ea33998
Add uname command, Update uptime comand (#3909)
* Add uname support

* Changelog addition

* Migration to platform module

* Update uptime.py for the last version
Merge the original uptime module to a single file
Change the bootime() return be stay compatible with xonsh
Add support for Haiku , suppose to close #3882
Add dependency from uptime to support to MacOS 10.10 by add _posix.c file.

* Update uptime.py for the last version
Merge the original uptime module to a single file
Change the bootime() return be stay compatible with xonsh
Add support for Haiku , suppose to close #3882
Add dependency from uptime to support to MacOS 10.10 by add _posix.c file.

* typo fix

* black reformat

* remove usage of print

* black is black

* add original test for uptime
convert original test via 2to3
black reformat tests

* strange syntaxe fixe for flaske8

* black the incredible tool it stop a bug fixe just because it THE tool it want a return for make less readable code

* flake8 the famous tool it permit to stop a big fixe without any information's about the trouble

* workaround about xonsh CI don't respect docstring specs

* RISC OS only comment thing

* black is a good jock in a CI

* black is a good jock in a CI

* roll back uptime.py

* look if we can make it work

* fixe all i understand

* add command in corutils alias

* reformat uptime.py with black

* fixe version

* try with xonsh xp.LIBC lib

* black in a CI is a stupid thing

* stupid Windows and it \r

* use os.linestep

* use newline simple wrapper

* use newline simple wrapper

* use newline simple wrapper

* use newline simple wrapper

* try osx rollback method

* fixe

* fixe

* a test on window via the CI because i haven't the OS

* a test on window via the CI because i haven't the OS

* a test on window via the CI because i haven't the OS

* fix: black: format

* refactor: update uname command

now has auto-completions

* docs: update news item and fix qa error

* refactor: remove unused file

* fix: qa imports

* refactor: update getting boottime

fallback to monotonic time on unix

* fix: update haiku compatibility in uptime

* refactor: add uptime to aliases

* refactor: move xoreutils tests

* fix: call aliases using xonsh

Co-authored-by: Tuux <tuxa@rtnp.org>
Co-authored-by: Noortheen Raja <jnoortheen@gmail.com>
2022-01-08 18:28:46 +05:30
Noorhteen Raja NJ
7c4e207abd
update test xsh usage (#4581)
* todo

* test: remove usage of DummyEnv and setting .env attribute on xession fixture

one step closer to making too much of tweaking to xession during tests

* test: fix tests vox and gitstatus-prompt

* docs: update test-fixture usage

* fix: import flake8 error

* test: remove direct access to XSH in tests

* test: remove usage of XSH in test files

* todo

* test: use tmp-dir to create stubs

* refactor: use fixture factory to mock out XonshSession

* refactor: remove direct access of XSH from functions

* refactor: remove direct access of XSH from functions

* fix: qa checks

* refactor: rename variables to match their values

* test: update failing tests because it had no PATH set previously

* fix: remove builtins usage from pyghooks.py

* style:

* refactor: update tests to use fixtures

* fix: env varialbe is setup per function

some tests accidentally update the env variables and that is leaking
into next tests

* fix: failing vox tests

* test: set commands_cache per test

* test: fix failing tests

* fix: failing tests on linux

ptk-highlight

* fix: failing tests on Windows

cwd-prompt

* test: copy env as to not affect original object

* fix: lazily evaluate cmds-cache in pyghooks

* test: fix failing tests

* fix: qa errors import

* test: set commands-cache per test

while caching path results

* test: speedup test_thread_local_swap

* fix: failing tests on windows

* refactor: Execer doesn't control session

* refactor: XSH.unload will take care of reversing builtins attrs set

* test: use env.update over monkeypatch

* Revert "test: use env.update over monkeypatch"

This reverts commit 010a5022247a098f1741966b8af1bf758663480e.
2022-01-07 17:33:22 -05:00
Noorhteen Raja NJ
c01fc6efe3
refactor: do not override sys coreutils (#4617)
* refactor: do not override sys coreutils

* docs:
2022-01-05 09:44:53 -05:00
Noorhteen Raja NJ
cd57240237
fix: append space at the end of completions (#4611) 2021-12-23 18:27:37 +05:30
Noortheen Raja
f5367f6083 feat: add upgrade command
fixes #2095
2021-12-23 06:32:47 +05:30
Noorhteen Raja NJ
c2d25ac251
pre-commit hook for pyupgrade (#4583)
* chore: add pyupgrade

* refactor: upgrade code to py3.7+

ran `pre-commit run pyupgrade -a` while excluding changes to ply

* fix: flake errors
2021-12-06 14:42:26 -05:00
Noorhteen Raja NJ
b031047beb
add fish shell based completer (#4569)
* feat: add fish shell based completer

* refactor: use filter-func to filter results
2021-11-29 21:02:32 +05:30
Noorhteen Raja NJ
6d756ef7c9
Vox improvements (#4549)
* refactor: confirm before deleting the folder

fix: failing tests

* feat: shorter positional argument which is optional

cli-utils

* refactor: vox-default interpreter from system's default

* feat: add new vox commands info, wipe

* feat: add new vox commands toggle-ssp, runin, runinall

* feat: add new vox commands toggle-ssp, runin, runinall

* feat: add new vox commands project-set, project-get

* feat: implement vox new 'pip installs/requirements' and project linking

* test: update failing tests
2021-11-26 23:37:35 +05:30
Noorhteen Raja NJ
0c13e8c008
adding convention for short boolean flags (#4520)
* feat: use NumpyDoc to represent Parsed docstring

in cli_utils.py

* feat: set argparse boolean option from default values

* refactor: shorter Arg in annotation

by following convention in cli_utils.py

* fix: get description without Parameters

* fix: qa errors
2021-11-17 13:51:18 -05:00
Noorhteen Raja NJ
a3c1b2429e
argparserAlias - vox (#4437)
* feat: use argparser-alias for vox

* feat: vox.create --interpreter completions

* refactor: use func based completer

* fix: implement interpreter completion

* docs:

* refactor: update import path of cli_utils

* style: convert to f-strings

* fix: failing tests

* fix: failing tests

completer from base_completer appears
2021-10-13 10:02:06 -04:00
Noorhteen Raja NJ
ca9338149c
fix: vox system_site_packages option not passed (#4404)
* fix: vox system_site_packages option not passed

* docs: add news item

* docs: add todo nit
2021-08-11 09:46:32 +03:00
Daniel Shimon
8dac83a9a0
Fix jedi path completion (#4400)
* xontrib: jedi: Don't complete paths with '~'

* tests: xontrib: jedi: Update tests

* news: Add fix-jedi-path-completion
2021-07-29 10:02:25 +03:00
Noorhteen Raja NJ
3ce8c9b337
add py310 (#4270)
* chore: adding py310 to ci

though this will require code/parser changes, this is to prepare for
upcoming adoption

* fix: set python version as string

* fix: reference to master -> main

* fix: coverage is not reported in master

- disable amalgamation
	1. during coverage report tests
	2. qa tools like mypy may follow imports
- use python 3.9 for coverage and qa report. since it will have more
coverage and better typing support

* chore: use py3.10 with setup-py action

* chore: add news-item check job

* fix: py3.10 error while starting

the match statement is not supported.
while the syntax support is only upto py3.8

* fix: news-item checker

* chore: enable fail report for py310 tests

* test: add test for ptk_shell
2021-06-07 13:40:40 -04:00
Noorhteen Raja NJ
948129b7a0
feat: add flake8-bugbear (#4288)
* feat: add flake8-bugbear

* style: remove pylint disable comments

* chore: add flake8 as pre-push check

* chore: add bunch pf pre-commit hooks

* style: remove hasattr __call__
2021-05-26 23:15:34 +03:00
Noorhteen Raja NJ
38295a1dd9
Remove globals (#4280)
* refactor: remove usage of global variables in abbrevs.py

* chore: add flake8-mutable to prevent mutable defaults

* fix: abbrevs expand test

* refactor: add xonsh session singleton

* refactor: fix circular errors when using xonshSession as singleton

* refactor: remove black magicked builtin attributes

* style: black format tests as well

* refactor: update tests to use xonsh-session singleton

* refactor: update abbrevs to not use builtins

* test: remove DummyCommandsCache and patch orig class

* fix: failing test_command_completers

* test: use monkeypatch to update xession fixture

* fix: failing test_pipelines

* fix: failing test_main

* chore: run test suit as single invocation

* test: fix tests/test_xonsh.xsh

* refactor: remove builtins from docs/conf.py

* fix: mypy error in jobs

* fix: test error from test_main

* test: close xession error in test_command_completers

* chore: use pytest-cov for reporting coverage

this will include subprocess calls, and will increase coverage

* style:
2021-05-20 13:14:26 +03:00
Daniel Shimon
f960d4576f
Improve jedi completer (#4264)
* xontrib: jedi: Don't complete partial paths in commands

E.g. when completing "/bin/a" we don't want jedi to complete "/bin/abs"

* xontrib: jedi: Allow case-insensitive completions

* news: Add improve-jedi-completer
2021-05-11 13:10:58 +03:00
Daniel Shimon
224fc55e41
Completion context (#4017)
* completion-context: Add CompletionContextParser placeholder

Implements the xonsh (tab-)completion context parser.
This parser is meant to parse a (possibly incomplete) command line.

* completers: tools: Implement ``contextual_completer`` decorator

This is used to mark completers that want to use the parsed completion context.

* completers: Enable using contextual completers in xonsh/completer.py

* completers: readline, ptk, jupyter: Enable using contextual completers

Pass ``multiline_text`` and ``cursor_index`` to ``Completer.complete()``

* parsers: base: Refactor out a ``raise_parse_error`` function

* tokenize: Enable ``tolerant`` mode

If ``tolerant`` is True, yield ERRORTOKEN instead of
    throwing an exception when encountering an error.

* lexer: Enable ``tolerant`` mode

Tokenize without extra checks (e.g. paren matching).
When True, ERRORTOKEN contains the erroneous string instead of an error msg.

* tests: lexer: Test ``tolerant`` mode

* completion-context: Implement simple CommandContext parsing

* completion-context: tests: Test simple CommandContext parsing

* completion-context: Implement parsing sub-commands

* completion-context: tests: Test parsing sub-commands

* completion-context: Add news file

* completion-context: parser: Add parser table path to relevant locations

Code-coverage, mypy ignore list, etc.

* completion-context: Implement parsing partial strings and line continuations

* completion-context: tests: Test parsing partial strings and line continuations

* completion-context: Convert ``Span`` object to a ``slice``

* completion-context: Refactor out ``create_command`` and ``cursor_in_span``

* completion-context: Implement handling empty commands

* completion-context: tests: Test handling empty commands

* completion-context: Implement handling multiple commands

Separated by newlines, `;`, `and`, `or`, `|`, `&&`, `||`

* completion-context: tests: Test handling multiple commands

Separated by newlines, `;`, `and`, `or`, `|`, `&&`, `||`

* completion-context: Implement handling python context

* completion-context: tests: Test handling python context

* completers: tools: Add `contextual_command_completer`

* completers: Make `complete_skipper` contextual

* completers: Make `complete_from_man` contextual

* completers: Make `complete_from_bash` contextual and add test

* completers: Make `complete_pip` contextual and update tests

* completers: Keep opening string quote if it exists

* completion-context: Handle cursor after a closing quote

For example - cursor at the end of ``ls "/usr/"``.
1. The closing quote will be appended to all completions.
 I.e the completion ``/usr/bin`` will turn into ``/usr/bin"``
2. If not specified, lprefix will cover the closing prefix.
 I.e for ``ls "/usr/"``, the default lprefix will be 6 to include the closing quote.

* completion-context: tests: Test handling cursor after a closing quote

* completion-context: Fix bug with multiple empty commands

e.g. `;;;`

* completion-context: tests: Speed up tests

From ~15 seconds to ~500 ms

* completion-context: Expand commands and subcommands

* completion-context: Simplify `commands` rules

* completion-context: Simplify `sub_expression` rules

* completion-context: Simplify editing a multi-command token

* completion-context: Inline `create_command`

* completion-context: Implement `contextual_command_completer_for` helper

* completers: Make `complete_cd`/`complete_rmdir` contextual and add tests

* completers: path: Don't append a double-backslash in a raw string

When completing a path, if a raw string is used (e.g. `r"C:\Windows\"`),
there's no reason to append a double-backslash (e.g. `r"C:\Windows\\"`).

* completers: Make `complete_xonfig`/`complete_xontrib` contextual and add tests

* completers: Make `complete_completer` contextual and add tests

* completers: Make `complete_import` contextual and add tests

* completion-context: Add python `ctx` attribute

* completion: tools: Simplify `RichCompletion` attributes handling

* completers: Make `base`, `python`, and `commands` contextual

* Add tests
* No need for `python_mode` completer anymore

* completion: tools: Add `append_space` attribute to `RichCompletion`

* completion-context: Get all lines in a main python context

* xontrib: jedi: Make the `jedi` completer contextual

* completers: tools: Remove `get_ptk_completer` and `PromptToolkitCompleter.current_document`

These aren't needed anymore now that contextual completers can access the multiline code (via `PythonContext.multiline_code`).

* completion-context: ptk: Expand aliases

* completion-context: jupyter: Expand aliases and fix line handling

* completer: Preserve custom prefix after closing quote

* completers: bash: Ensure bash completion uses the complete prefix

* completers: pip: Append a space after a pip command

* completers: pip: Prevent bad package name completions

* completers: Remove a common prefix from `RichCompletion` if `display` wasn't provided

* completion-context: Treat cursor at edge of `&& || | ;` as normal args

This will be used for completing a space

* completers: Complete end proc keywords correctly
2021-03-30 13:37:56 -04:00
Noorhteen Raja NJ
b7b2c9a916
fix: abbrevs with callback alters buffer text before expansion (#4156)
* fix: abbrevs with callback alters buffer text before expansion

fixes #3642

* docs: add news item
2021-03-09 09:07:53 -05:00
Noorhteen Raja NJ
d50cf32f84
Feat abbrevs callback (#4031)
* feat: support callbacks in abbrevs dict

facilitate solving problems like #3642

fixes #3642

* test: add tests for abbrevs and news item

* fix: mypy error

* refactor: update imports for xontrib_meta module
2021-01-29 12:18:22 -05:00
Noorhteen Raja NJ
80aca856e4
refactor: convert prompt_ret_code to be a py file (#4032)
to take advantage of flake/coverage
2021-01-12 13:35:38 -05:00
Faris A Chugthai
b4aa80f097
Add brackets to ambiguous data type (#3981)
Without the brackets python defaults to assuming that the iterable is a tuple. In the reference guide `__all__` is explicitly stated to be of type `list`.

Functionally I'll admit this doesn't change anything but to observe the correct usage pattern of `__all__`, simply add the brackets.
2021-01-05 11:26:09 -05:00
Noortheen Raja
7fe724255f feat: upgrade black version to 20.8b1
this changes docstring indendation
but facilitates additional control over new lines with comma
2020-11-25 12:46:35 +05:30
Noorhteen Raja NJ
5ea2ae4f8f
refactor: rewrite xontribs/jedi.xsh -> xontribs/jedi.py to take advan… (#3965)
* refactor: rewrite xontribs/jedi.xsh -> xontribs/jedi.py to take advantage of python tooling

* chore: update elm ci workflow

* test: update test for jedi xontrib
2020-11-23 16:21:43 -05:00
Noortheen Raja
8c88030d6b refactor: some backlog from when flake8 setup 2020-11-08 23:31:10 +05:30
David Strobach
cc5ef74cd7
Add xog xontrib (#3896)
* Changelog entry

* Add xog xontrib

A simple command to establish and print temporary traceback log file.
2020-10-17 11:53:00 -04:00
Noortheen Raja
197251e818 fix: during amalgamate it removes type-ignore comments 2020-10-09 20:19:09 +05:30
a
b8caf65534 no_color to reset 2020-10-09 01:04:52 +03:00
a
19ea4d3af9 Bashisms shopt, complete 2020-09-25 09:57:36 +03:00
a
c3eb629912 new 2020-09-25 00:00:56 +03:00
a
b00cf677ad Mr. Black 2020-09-24 23:28:41 +03:00
anki-code
526bccef36
bashisms set 2020-09-24 23:13:20 +03:00
Bob Hyman
88bba37c3a Merge branch 'master' into environment_fixes 2020-09-23 04:40:26 -04:00
a
08765c4c90 black 2020-09-22 00:11:21 +03:00
anki-code
7f15ff0a64
Delete whole word with Shift+Del
Here should be Control+Backspace but https://github.com/prompt-toolkit/python-prompt-toolkit/issues/257#issuecomment-190328366
2020-09-21 23:51:36 +03:00
Bob Hyman
a9048d2841 Allow "ANSICON", "TERM", "VIRTUAL_ENV" registered envvars to not be in env. 2020-09-07 20:39:35 -04:00
David Strobach
0e2846d66a Use f-string as per the reviewer request 2020-08-28 16:53:45 +02:00
David Strobach
dc0b8a6839 black 2020-08-28 16:53:45 +02:00
David Strobach
dd4088b61d vox: Add combo new+activate and deactivate+rm actions
Implemented via "vox new --activate" and "vox deactivate --remove".
2020-08-28 16:53:45 +02:00
David Strobach
f4794caef7 vox: Fix virtual environment removal
Virtual environment was impossible to delete after
activation/deactivation cycle.
2020-08-23 20:49:32 +02:00
David Strobach
5c2e5a3d8d vox: Restore vox functionality
After the recent changes in environment defaults, the vox xontrib
could not "see" the virtual environments and work with them.
2020-08-23 11:16:26 +02:00
David Strobach
9ba2eb5934 abbrevs: Allow for setting cursor position within expanded abbrev 2020-08-13 14:12:16 +02:00
Anthony Scopatz
a816084d44
Merge pull request #3650 from daniel-shimon/improve-completers
Add tests and fix bugs for RichCompletion and Jedi xontrib
2020-08-04 21:11:47 -05:00
Daniel Shimon
5f8e27b666 xontrib: jedi: Fix bugs in jedi completer 2020-08-05 00:15:17 +03:00
David Strobach
7cf5a91673 Revert abbrevs expansion on the second consecutive space keypress 2020-08-04 16:19:41 +02:00
Anthony Scopatz
41a600de51 Merge branch 'patch-1' of https://github.com/sfermigier/xonsh into vox-rm 2020-08-01 14:37:38 -05:00