Commit graph

1616 commits

Author SHA1 Message Date
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
Peter Ye
d33d60ee3e
Fix the handling of colons when mixed with comments (#4332)
* Add ends_with_colon_token tool

* Add execer test for comment ending with a colon

* Use ends_with_colon_token() to catch non-indented blocks in execer

* Use ends_with_colon_token() for automatic indentation in prompt_toolkit and readline

* Add news
2021-06-20 12:50:03 +03:00
Peter Ye
7a58071d1f
Fix atdollar_no_output test (#4322) 2021-06-14 08:47:05 +03:00
Noorhteen Raja NJ
f3d314bc36
chore: move news items check to qa (#4314)
fixes #4313
2021-06-11 15:01:35 +03:00
Peter Ye
354f446f54
Fix empty command error message (#4308)
* fix pathsplit

* fix error message for empty command

* add news

* fix formatting

* fix atdollar_no_output test
2021-06-11 14:11:19 +03:00
Noorhteen Raja NJ
45b588c52e
feat: add config option to hide gitstatus prompt fields (#4294)
* refactor: create namedConstants for std colors

* feat: add gitstatus hide option

* test: update test_vc to not leak xsh object
2021-06-11 02:24:24 +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
Daniel Shimon
4c055d82e8
Update completer cli (#4299)
* completers: Add new completers after the non-exclusives

* completer: Print whether a completer is non-exclusive

* news: Add update-completer-cli
2021-05-30 09:42:55 +03:00
Daniel Shimon
7f8aeefae8
tests: Run tests with the amalgamated xonsh (#4290)
* tests: Run tests with the amalgamated xonsh

* tests: Test xonsh loads correctly interactively

* tests: Ensure tests run from amalgamated xonsh

* environ: Separate $XONSH_DEBUG and $XONSH_NO_AMALGAMATE

* tests: Keep XONSH_NO_AMALGAMATE in a comment for ease of debugging

* tests: Fix monkeypatch for amalgamated code
2021-05-28 15:42:37 +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
Gordon Ball
e02c7d76c4
Test RC loading in different startup configurations (#4279)
* test_main: test lots of startup order combinations

This is based on the startup order described in
https://github.com/xonsh/xonsh/issues/4096#issuecomment-791991841
and adds an (ugly) parameterised test which tries lots of different
CLI combinations, and verifies which RC files (if any) get loaded,
and in what order.

* test_script_startup: skip on windows
2021-05-14 16:12:34 +03:00
Daniel Shimon
27db574d99
Fix annotated assignment (#4278)
* ast: Fix annotated assignment

* ast: Support annotated variable without a value

* tests: Test annotated assign statements

* news: Add annotated-assignment
2021-05-12 12:39:11 -04:00
Gordon Ball
d48c93bdb5
Add support for rc.d drop-in configuration directories (#4256)
* Add support for rc.d drop-in configuration directories

* main: change how --rc, --no-rc are handled

Explicitly pass --no-rc rather than signalling it as an empty --rc, to
indicate that we should suppress both XONSHRC and XONSHRCDIR in that
case.

* Rename XONSHRCDIR -> XONSHRC_DIR

* xonshrc_context: document setting env for XONSHRC_DIR

* main: --rc foo.xsh should suppress XONSHRC_DIR
2021-05-11 16:42:37 -04:00
Gyuri Horak
9400a7cbd4
Fix for crash if $XONSH_COLOR_STYLE is set to something invalid (#4253)
* Fix crash if gruvbox is set to something invalid

* unit test for `ansi_style_by_name` + news
2021-05-11 15:51:50 -04:00
Daniel Shimon
fe63279d26
Fix skip completer (#4263)
* completer: Refactor out complete_from_context

* completers: Fix `skip` completer calculation and completers invocation

* tests: Test commands completers

* news: Add fix-skip-completer

* completers: Make `complete_path` contextual
2021-05-11 15:49:45 -04:00
Andy Kipp
09b31bec10
feat: Add saving current working directory (cwd) to the history (#4271)
* Add saving current working directory (cwd) to the history

* Added XONSH_HISTORY_SAVE_CWD and create PromptHistorySetting section

* news

* Move dummy history to the distinct file

* tests

* tests

Co-authored-by: a <a@a.a>
2021-05-11 15:23:57 -04:00
Daniel Shimon
6df8fe9ba7
Non exclusive completers (#4259)
* completers: Move `apply_lprefix` to completers/tools.py

* completers: Implement non-exclusive completers

* completers: Make end_proc keywords and tokens non-exclusive

* completers: Implement environment vars non-exclusive completer

* news: Add non-exclusive-completers
2021-05-11 09:50:40 -04: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
35f1ba1819
Improve import completions (#4265)
* completers: import: Move `import` completer before `bash` completer

If this completer returns a result, it's definitely an import statement

* completers: import: Complete `import` keyword in `from ... import` statements

* news: Add improve-import-completions
2021-05-11 01:48:53 +03:00
Andy Kipp
0dc896c284
feat: Ability to call the program by name from callable alias with the same name without the infinite loop error (#4218)
* fix aliases infinite loop

* black

* cleaning

* skip_if_on_windows

* skip_if_on_windows

* bump tests

* bump tests

* skip test

* remove skipping test

* Update xonsh/procs/specs.py

Co-authored-by: Daniel Shimon <daniel.shimon22@gmail.com>

* Update xonsh/procs/proxies.py

Co-authored-by: Daniel Shimon <daniel.shimon22@gmail.com>

* Make alias names internal

* Tests

* Tests

* Tests

* tests

Co-authored-by: a <a@a.a>
Co-authored-by: Daniel Shimon <daniel.shimon22@gmail.com>
2021-05-10 09:30:41 -04:00
Noorhteen Raja NJ
4dc08232e6
Fix commands cache testing (#4257)
* fix: update failing commands-cache tests

in some cases, the thread updates the binaries faster than the next call

* chore: upgrade black to 21.5b0

* chore: upgrade mypy to 0.812 version

* fix: handle corrupt commands-cache file

* fix: parser-table output dir. this should be same as the defaults

* fix: flake8 error
2021-05-06 09:54:09 -04:00
Andy Kipp
6d0c23e16f
Close 4215: Added env variable to ignore ./ and ../ in filepath completion (#4241)
* Added env variable to ignore ./ and ../ in filepath completion

* Changed ignore_dots to complete dots as always, never, or upon matching

* Updated news

* Added default 'matching'

* Update ignore_dots.rst

* black

* fix test

* tests

Co-authored-by: Bailey Morgan <bailey.mccarty.morgan@gmail.com>
Co-authored-by: a <a@a.a>
2021-04-27 09:28:17 -04:00
Noorhteen Raja NJ
cb7db29991
Feature/speed up startup (#4106)
* feat: use saved commands_cache between runs

this will speed-up startup time by a small factor (around 0.15s on my
system with ssd and ryzen5)

* test: update env-variable handling for cmds-cache tests

* refactor: add env-variable to control saving commands-cache

* refactor: mypy error fix for commands_cache

* fix: update handling max(iterable

* test: add tests for commands-cache new version

* docs: update env variable doc

* test: add more test for commands-cache caching behaviour
2021-04-21 11:38:06 -04:00
Andy Kipp
039ce96dcd
feat: Added ability to get arguments list in ExecAlias (#4201)
* black

* news

* test

* alias_argN

* ExecAlias docs

* note about merge operator

* $args

* docs

Co-authored-by: a <a@a.a>
2021-04-15 09:39:13 -04:00
Andy Kipp
3785cbf8b4
XONSH_SUBPROC_CAPTURED_PRINT_STDERR to False (#4231)
Co-authored-by: a <a@a.a>
2021-04-13 13:21:43 -04:00