Commit graph

1740 commits

Author SHA1 Message Date
Noorhteen Raja NJ
5a985427e7
feat: add sub-command to print current completions (#4586)
* feat: `completer complete` command is added to test current completions

* fix: tests
2021-12-12 08:47:47 +05:30
Noorhteen Raja NJ
7ee5b26064
feat: update command completions to show description as well (#4488)
* feat: update command completions to show description as well

closes #3823

* test: fix failing tests on windows

* fix: failing tests on windows machine
2021-12-07 10:33:41 -05:00
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
b2516737b6
code refactor (#4571)
* style:

* refactor: tests of xoreutils
2021-11-30 08:23:32 -05:00
Noorhteen Raja NJ
9a8cc74c4b
refactor: remove xonsh.ptk2 module (#4570) 2021-11-30 08:22:31 -05:00
Noorhteen Raja NJ
0053d55e3d
feat: auto-completion support for source-foreign (#4564)
* feat: auto-completion support for source-foreign

* feat: add completions for source-bash/zsh/cmd

* refactor: change the boolean flags names that defaults to True
2021-11-27 16:28:04 +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
5f0ec33447
Ap/aliases completer (#4486)
* feat: create field to define alias-completer

this will resolve checking parser or alias. Now the alias can define how
it completes.

will solve
https://github.com/xonsh/xonsh/pull/4267#discussion_r676066853

* docs:

* fix: mypy error

* fix: rst qa

* style:
2021-11-23 12:34:12 -05:00
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
Kaarel Pärtel
8da06b4446
fix: escape curly braces for the prompt cwd (#4511)
If a directory was named for example '{RED}', that would get
interpreted as a color string and the prompt would not show the
direcotry name and would color it instead. Using dir names like
'{{foo}}' or simply '{' would break the prompt outright.

There was not much documentation on the prompt formating, but it seems
that escaping a curly by doubling it makes the prompt display all
curlies correctly.

fixes #4381
2021-11-17 13:39:28 -05:00
Noorhteen Raja NJ
d51a03bc74
fix: random test failures on macos (#4518) 2021-10-15 08:53:30 -04:00
Noorhteen Raja NJ
20ef5a033c
Ap/trace (#4453)
* feat: use argparser-alias for trace

* test: add test for trace cli

* fix: qs

* fix: update import path

* docs:
2021-10-13 10:04:59 -04: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
33a5689db2
feat: improve pip completer (#4476)
* feat: improve pip completer

* refactor: optimize imports

* fix: update tests for other completers

* fix: failing tests

* test: fix failing tests

* refactor: make error message clear

exception like KeyError will be more clear now

* qs import

* fix: failing tests on windows

* fix: failing tests on windows

* fix: failing tests on windows

* refactor: optimize imports
2021-09-26 11:33:09 -04:00
Noorhteen Raja NJ
50a1c92004
chore: enable flake8 for tests (#4482) 2021-09-26 11:32:24 -04:00
Noorhteen Raja NJ
1c2be53040
refactor: remove redundant code (#4478) 2021-09-21 16:55:10 -04:00
Daniel Shimon
7ce53f1844
Always capture aliases (#4445)
* specs: Make sure sub-specs are always captured regardless of $XONSH_CAPTURE_ALWAYS

* procs: Ensure env is used in functional aliases

* news: Add always-capture-aliases

* tests: procs: Skip known issues

* tests: Restore all builtins in the 'xonsh_builtins' fixture

* tests: vc: Use monkeypatch to mock CommandsCache functions

* tests: main: Don't use the local machine's xonshrc
2021-09-15 15:14:28 -04:00
Michael Ramsey
c04a0997ed
Fix: EnvPath.add() not maintain uniqueness with Path objects on replace (#4461)
* Fix: EnvPath.add() not maintain uniqueness with Path objects on replace

* Update tools.py

Removed commented out code left in originally

* Add tests for EnvPath.add() function

* Add test for EnvPath.add() function with pathlib path

* Update tests for EnvPath.add() function to support winblows paths

* Fix xontribs meta page so github links clickable and one minor typo

* Update xonsh/xontribs_meta.py

updated as requested

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

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2021-09-14 12:54:18 -04:00
Daniel Shimon
438c66dfc0
Env swap thread safety (#4465)
* environ: Implement InternalEnvironDict for thread-local overrides

* environ: Make `swap` thread-safe without leaks

Use thread-local storage to override the changes.
This way the changes can't leak to other threads.

* environ: Implement 'get/set_swapped_values' to pass to threads

* procs: Use swapped values in threaded subprocs

This is so the thread will use the same swapped values as the origin one.

* news: Add env-swap-thread-safety
2021-09-13 11:06:55 -04:00
Daniel Shimon
6df8a24fc9
Path completion in python code (#4457)
* completions: path: Fix completing a single-arg python code segment

* tests: completions: path: Test completing python code

* news: Add path-completion-in-python-code
2021-09-07 01:23:49 +03:00
Noorhteen Raja NJ
89f54ee10a
Ap/history (#4454)
* feat: use ArgParserAlias for history command

* feat: cli-utils: support parsing unknown args

* feat: use _unparsed for getting history slices

* fix: use show cmd as default

* fix: update history-diff to allow new format

* fix: make sure that history files are flushed

* fix: remove unused imports

* docs:

* fix: annotation error in older py versions

* refactor: split dispatch function
so that one can intervene before final call

* fix: py3.6-7 has no mock.call_args.kwargs properties

* fix: update _dispatch_func signature

* test: update tests for history-show parser

* fix: amalgam different import path

* fix: cli_utils not amalgamated

when importing as `from xonsh.cli_utils import ...` it is not lazy
loading
2021-09-06 21:38:37 +03:00
Noorhteen Raja NJ
d701ea7282
test: improve ptk_shell tests (#4448)
* test: improve ptk_shell tests

* Update tests

* fix: failing tests
2021-09-03 10:56:05 -04:00
Noorhteen Raja NJ
0a4720b71a
feat: use ArgparserAlias for xontrib (#4441)
* feat: use ArgparserAlias for xontrib

* test: add test for xontrib-name-completer

* fix: bashisms tests should unload module after tests

* test: make assertion failure message obvious

* fix: failing tests because autovox is already loaded in some py versions
2021-09-02 22:17:45 +03:00
Noorhteen Raja NJ
e25ab34e32
Add test for readline shell (#4447)
* fix: ReadlineShell pass stdin/out to Cmd's constructor

* test: add test for readline shell

* chore: increase required coverage

* test:

* fix: failing ci pipeline

* fix: failing ci test
2021-09-02 22:15:20 +03:00
Noorhteen Raja NJ
6c22b84f80
Ap/disown (#4442)
* feat: use ArgParserAlias for disown command

* feat: add rich-completer

* docs: add news item

* fix: mypy error

* test: add disown completer tests
2021-08-28 19:38:05 +03:00
Noorhteen Raja NJ
076098899a
feat: use argparserAlias for xexec (#4440)
* feat: use argparserAlias for xexec

* docs: news item

* docs: add todo

* fix: failing tests

* fix: failing tests

* fix: update xexec--help test

* feat: add epilog if available to argparse

* feat: implement epilog section for xexec

* docs:
2021-08-28 17:23:20 +03:00
Noorhteen Raja NJ
c4b54e06a1
ArgparserAlias - xonfig2 (#4436)
* feat: use ArgparserAlias for xonfig

* test: update test for xonfig completions

* refactor: update docs

* refactor: use function based completer

* fix: remove old import

* docs:

* fix: merge issues

* test: move xsh_with_aliases to root conftest.py

* docs:

* feat: set subparser's prog from func-name
2021-08-28 14:09:59 +03:00
Noorhteen Raja NJ
54f5ae7bb2
Argparser/color+completion (#4391)
* feat: add colored help formatter and alias builder

closes #4284

* feat: add auto-completion support to argparser

* test: update test for completer

* fix: getting doc from params that have annotation

* refactor: use filter-function for checking alias completions

* doc: add discussion abount check for alias having parser

see discussion on
https://github.com/xonsh/xonsh/pull/4267

* type fix

* refactor: use function based completer

* test: fix failing argparser test

* docs: update news item

* update completion for argparser sub-commands to append_space

from comment on
https://github.com/xonsh/xonsh/pull/4267#discussion_r676044508

* docs: update docstring typo

* refactor: move inspect import to top

* feat: support option strings before positionals

and add env setting for showing completions for options by default

* test: update tests after adding new $ALIAS_COMPLETIONS_OPTIONS_BY_DEFAULT

* add suggested completion_context_parse fixture

* docs: add suggested doc for dispatch function

* refactor: use try/except for import of typing.annotated

* refactor: move complete_argparser_aliases to completers/aliases.py

* refactor: move argparser completer to its own module

* style:

* refactor: rename completer to not clash with argparse

* fix: expand option's descriptions

* fix: add completer/argparser to amalgam
2021-08-26 01:32:13 +03:00
Noorhteen Raja NJ
abc98c1bb3
Lab/pretty print test (#4425)
* feat: py2 handling is no longer needed

* feat: add pretty printer tests

* fix: failing tests
2021-08-24 09:29:39 +03:00
Noorhteen Raja NJ
d7dbfa9011
Lab/py control file (#4420)
* feat: use python's compile for rc.py

* docs: add news item

* docs: update news item

* test: add tests for py-control files

* fix: rst news item

* docs: update news item

* docs: add sample rc.py
2021-08-19 12:40:22 -04:00
Gordon Ball
e59ac28d7d
Support --rc DIR (#4422)
* args: accept --rc dir to load dir/*.xsh

* test_main: add a test for --rc dir

* args: drop unused --config-path, not read anywhere

* news: add entry for rcdir changes
2021-08-19 12:14:20 -04:00
Gordon Ball
14c2c3ce62
Don't modify XONSHRC and XONSHRC_DIR during startup (#4408)
* xonshrc_context: return loaded instead of context, don't touch env

This function returned the context, but the return value is not used by
the sole call site (and would inconsistently be either the env or ctx
depending on other arguments). Redefine the function to return what was
loaded.

The function will also no longer touch the environment variables
XONSHRC, XONSHRC_DIR or LOADED_RC_FILES.

* XonshSession: add rc_files list, and set in start_services

* LOADED_RC_FILES: drop completely

* xonfig: add RC files

* test_main: update tests for changes to XONSHRC{,_DIR}

* news: add entry for xonshrc changes
2021-08-17 11:01:41 -04:00
Ali Uneri
e955591bcb
Use full paths when launching processes on Windows (#4077)
* Use full paths when launching processes on Windows

Addresses issue #3763.

* Add news item

* Suppress stderr from "which"

* Replace xonsh.xoreutils.which with shutil.which

* Use existing resolved binary location

* Ensure PATHEXT mock is not overwritten

* Add tests for running excutables on windows

* Ensure we don't set overwrite command when binary_loc is none

* tweak tests

* Revert "Ensure PATHEXT mock is not overwritten"

This reverts commit ce5d6ac091.

* Use monkeypatch for chdir

Co-authored-by: Morten Lund <melund@gmail.com>
2021-08-16 22:02:12 +03:00
Daniel Shimon
5c2938c77c
Improve import completions (#4396)
* completers: Add 'import' completion functions from ipython

* completers: Add 'import' completions cache

* completers: Use ipython logic for 'import' completions

* completers: Use ipython logic in completing imported objects

* news: Add improve-import-completions

* tests: completers: Update 'import' completions tests

* completers: Apply lint to new 'import' completions

* completers: Check objects from __all__ are modules when needed

* tests: completers: Add multiple imports tests
2021-08-16 12:01:50 -04:00
Noorhteen Raja NJ
bb0cf18f7b
refactor: flaky test_xexec. (#4415)
when run alone will fail
2021-08-16 09:25:27 +03: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
Noorhteen Raja NJ
8831aca57f
test: speedup test suit by reusing costly vars (#4384)
* test: speedup test suit by reusing costly vars

* chore: revert changes to xonsh_execer fixture

* revert changes to test_parser
2021-08-10 10:17:20 +03:00
Peter Ye
d08006b0e0
Change !() to also capture background subprocesses (#4406)
* Change !() to also capture background subprocesses

* Add test

* Add news

* Simplify logic
2021-08-01 21:58:19 +03:00
Daniel Shimon
5322aafc66
Complete environment description (#4397)
* completers: env: Add env var's description

* news: Add complete-environment-description

* completers: env: Use generator

* completers: env: Show var type in display

* tests: completers: env: Update tests
2021-08-01 00:37:54 +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
9ae302fb11
feat: use rst-linter for news items check (#4398) 2021-07-28 10:16:35 -04:00
Noorhteen Raja NJ
73cf0c27be
test: remove redundant xonsh session mock fixture (#4390)
xonsh_execer
2021-07-25 18:38:10 +03:00
Noorhteen Raja NJ
112440ef63
feat: support var-args signature for aliases (#4379)
* feat: support var-args signature for aliases

* test: add test for callable alias
2021-07-25 13:15:05 +03:00
Gyuri Horak
98d4d2a184
Short color token name support for register_custom_style() (#4339) (#4342) 2021-07-24 18:37:51 +03:00
Jeremy Schlatter
09fcab65d2
fix surprising scoping behavior in execx and xonsh -c (#4363) (#4364)
* fix #4363

* fix test_integrations.py

* add tests for issue 4363

* fix regression

* add news item

* fix formatting with black

* fix news formatting
2021-07-24 17:17:37 +03:00
Noorhteen Raja NJ
a52c364569
refactor: remove unused argument to parser (#4344) 2021-07-01 15:17:45 +03:00
Peter Ye
86f02c0341
Stop $() from silently capturing stderr (#4336)
* Stop $() from silently capturing stderr

* Add test
2021-06-24 09:43:21 -04:00
Peter Ye
715fb867b4
Fix parser for subprocess command with leading whitespace (#4331)
* Fix parser for subprocess command with leading whitespace

* Add tests for subprocess leading space

* Add news

* Parameterize parser tests
2021-06-22 18:42:01 +03:00
Daniel Shimon
f87be90d6f
procs: Add $XONSH_CAPTURE_ALWAYS variable for opt-in interactive capt… (#4283)
* procs: Add $XONSH_CAPTURE_ALWAYS variable for opt-in interactive capturing

* tests: Add tests for $XONSH_CAPTURE_ALWAYS

* tests: Fix tests wrt $XONSH_CAPTURE_ALWAYS

* news: Add optional-interractive-capture
2021-06-21 12:36:37 -04:00
Daniel Shimon
985773a5c1
completers: bash: Fix completing an empty prefix (#4316) 2021-06-20 12:54:36 +03:00