diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b12f6a7..fed5ce4 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,7 +23,7 @@ jobs: - name: Build Docs run: | - make svgs + FORCE_COLOR=1 make svgs make docs - name: Upload artifact diff --git a/docs/svgs/viv-cache-help.svg b/docs/svgs/viv-cache-help.svg new file mode 100644 index 0000000..ec3d67a --- /dev/null +++ b/docs/svgs/viv-cache-help.svg @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + viv cache --help + + + + + + + + + + usage: viv cache [-h] <sub-cmd> ... + +manage the viv vivenv cache + +options: +-h--help    show this help message and exit + +subcommand: +<sub-cmd> +info (i)    get metadata about a vivenv +remove (r)  remove a vivenv + + + + diff --git a/docs/svgs/viv-cache-info-help.svg b/docs/svgs/viv-cache-info-help.svg new file mode 100644 index 0000000..5c91e96 --- /dev/null +++ b/docs/svgs/viv-cache-info-help.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + viv cache info --help + + + + + + + + + + usage: viv cache info [-h] [-p] [-s] [--json] vivenv + +get metadata about a vivenv + +positional arguments: +vivenv        name/hash of vivenv + +options: +-h--help    show this help message and exit +-p--path    print the absolute path to the vivenv +-s--size    calculate size of vivenvs +--json        name:metadata json for vivenvs + + + + diff --git a/docs/svgs/viv-cache-remove-help.svg b/docs/svgs/viv-cache-remove-help.svg new file mode 100644 index 0000000..58a80f8 --- /dev/null +++ b/docs/svgs/viv-cache-remove-help.svg @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + viv cache remove --help + + + + + + + + + + usage: viv cache remove [-h] [vivenv ...] + +remove a vivenv + +positional arguments: +vivenv        name/hash of vivenv + +options: +-h--help    show this help message and exit + + + + diff --git a/docs/svgs/viv-exe-help.svg b/docs/svgs/viv-exe-help.svg new file mode 100644 index 0000000..cbf6eaf --- /dev/null +++ b/docs/svgs/viv-exe-help.svg @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + viv exe --help + + + + + + + + + + usage: viv exe [-h] vivenv cmd + +run binary/script in existing vivenv + +examples: +    viv exe <vivenv> python -- script.py +    viv exe <vivenv> python -- -m http.server + +positional arguments: +vivenv        name/hash of vivenv +cmd           command to to execute + +options: +-h--help    show this help message and exit + + + + diff --git a/docs/svgs/viv-freeze-help.svg b/docs/svgs/viv-freeze-help.svg new file mode 100644 index 0000000..f15f337 --- /dev/null +++ b/docs/svgs/viv-freeze-help.svg @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + viv freeze --help + + + + + + + + + + usage: viv freeze [-h] [-p {abs,rel}] [-s] [-r <path>] [-k] [reqs ...] + +create import statement from package spec + +positional arguments: +reqs                         requirements specifiers + +options: +-h--help                   show this help message and exit +-p--path {abs,rel}         generate line to add viv to sys.path +-s--standalone             generate standalone activation function +-r--requirements <path>    path/to/requirements.txt file +-k--keep                   preserve environment + + + + diff --git a/docs/svgs/viv-help.svg b/docs/svgs/viv-help.svg new file mode 100644 index 0000000..22ed303 --- /dev/null +++ b/docs/svgs/viv-help.svg @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + viv  --help + + + + + + + + + + usage: viv [-h] [-V] <sub-cmd> ... + +vivisn'tvenv +command line: `viv run typer rich-click -s ./script.py` +python api: __import__("viv").use("typer", "rich-click") + +options: +-h--help       show this help message and exit +-V--version    show program's version number and exit + +subcommands: +<sub-cmd> +list (l)       list vivenvs +shim (s)       generate viv-powered cli apps +run (r)        run an app/script with an on-demand venv +exe (e)        run binary/script in existing vivenv +cache (c)      manage the viv vivenv cache +freeze (f)     create import statement from package spec +manage (m)     manage viv itself + + + + diff --git a/docs/svgs/viv-list-help.svg b/docs/svgs/viv-list-help.svg new file mode 100644 index 0000000..4e4bc41 --- /dev/null +++ b/docs/svgs/viv-list-help.svg @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + viv list --help + + + + + + + + + + usage: viv list [-h] [-v] [-q] [-f <key:value>] [-s] [--json] + +list vivenvs + +examples: +  `viv list \ +      --filter "accessed-after:2023-08-01"` +  `viv list -q --filter \ +    "created-before:$(date -d '2 weeks ago' +'%Y-%m-%d')"` +  `viv list --filter "files:./script.py"` +  `viv list --filter "files:None"` + +options: +-h--help                  show this help message and exit +-v--verbose               pretty print full metadata for vivenvs +-q--quiet                 show only ids +-f--filter <key:value>    filter vivenvs based on key:val +-s--size                  calculate size of vivenvs +--json                      name:metadata json for vivenvs + + + + diff --git a/docs/svgs/viv-manage-help.svg b/docs/svgs/viv-manage-help.svg new file mode 100644 index 0000000..254d133 --- /dev/null +++ b/docs/svgs/viv-manage-help.svg @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + viv manage --help + + + + + + + + + + usage: viv manage [-h] <sub-cmd> ... + +manage viv itself + +options: +-h--help     show this help message and exit + +subcommand: +<sub-cmd> +show (s)     show current installation +install (i)  install fresh viv +update (u)   update viv version +purge (p)    remove traces of viv + + + + diff --git a/docs/svgs/viv-manage-install-help.svg b/docs/svgs/viv-manage-install-help.svg new file mode 100644 index 0000000..eedcf58 --- /dev/null +++ b/docs/svgs/viv-manage-install-help.svg @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + viv manage install --help + + + + + + + + + + usage: viv manage install [-h] [-r <ref>] [-s <path>] [-c <path>] [-y] + +install fresh viv + +options: +-h--help          show this help message and exit +-r--ref <ref>     git reference (branch/tag/commit) +-s--src <path>    path/to/source_file +-c--cli <path>    path/to/cli (symlink to src) +-y--yes           respond yes to all prompts + + + + diff --git a/docs/svgs/viv-manage-purge-help.svg b/docs/svgs/viv-manage-purge-help.svg new file mode 100644 index 0000000..c9fc5f7 --- /dev/null +++ b/docs/svgs/viv-manage-purge-help.svg @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + viv manage purge --help + + + + + + + + + + usage: viv manage purge [-h] [-r <ref>] [-s <path>] [-c <path>] [-y] + +remove traces of viv + +options: +-h--help          show this help message and exit +-r--ref <ref>     git reference (branch/tag/commit) +-s--src <path>    path/to/source_file +-c--cli <path>    path/to/cli (symlink to src) +-y--yes           respond yes to all prompts + + + + diff --git a/docs/svgs/viv-manage-show-help.svg b/docs/svgs/viv-manage-show-help.svg new file mode 100644 index 0000000..a92163f --- /dev/null +++ b/docs/svgs/viv-manage-show-help.svg @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + viv manage show --help + + + + + + + + + + usage: viv manage show [-h] [-p] + +show current installation + +options: +-h--help          show this help message and exit +-p--pythonpath    show the path/to/install + + + + diff --git a/docs/svgs/viv-manage-update-help.svg b/docs/svgs/viv-manage-update-help.svg new file mode 100644 index 0000000..6f1dfb0 --- /dev/null +++ b/docs/svgs/viv-manage-update-help.svg @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + viv manage update --help + + + + + + + + + + usage: viv manage update [-h] [-r <ref>] [-s <path>] [-c <path>] [-y] + +update viv version + +options: +-h--help          show this help message and exit +-r--ref <ref>     git reference (branch/tag/commit) +-s--src <path>    path/to/source_file +-c--cli <path>    path/to/cli (symlink to src) +-y--yes           respond yes to all prompts + + + + diff --git a/docs/svgs/viv-run-help.svg b/docs/svgs/viv-run-help.svg new file mode 100644 index 0000000..f14c3ae --- /dev/null +++ b/docs/svgs/viv-run-help.svg @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + viv run --help + + + + + + + + + + usage: viv run [-h] [-s <path/url>] [-r <path>] [-k] [-b <bin>] [reqs  +...] + +run an app/script with an on-demand venv + +examples: +  viv r pycowsay -- "viv isn't venv\!" +  viv r rich -b python -- -m rich +  viv r -s <remote python script> + +positional arguments: +reqs                         requirements specifiers + +options: +-h--help                   show this help message and exit +-s--script <path/url>      script to execute +-r--requirements <path>    path/to/requirements.txt file +-k--keep                   preserve environment +-b--bin <bin>              console_script/script to invoke + + + + diff --git a/docs/svgs/viv-shim-help.svg b/docs/svgs/viv-shim-help.svg new file mode 100644 index 0000000..f4e708a --- /dev/null +++ b/docs/svgs/viv-shim-help.svg @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + viv shim --help + + + + + + + + + + usage: viv shim [-h] [-f] [-o <path>] [-p {abs,rel}] [-s] [-r <path>] +                [-b <bin>] [-y] +                [reqs ...] + +generate viv-powered cli apps + +examples: +  viv shim black +  viv shim yartsu -o ~/bin/yartsu --standalone + +positional arguments: +reqs                         requirements specifiers + +options: +-h--help                   show this help message and exit +-f--freeze                 freeze/resolve all dependencies +-o--output <path>          path/to/output file +-p--path {abs,rel}         generate line to add viv to sys.path +-s--standalone             generate standalone activation function +-r--requirements <path>    path/to/requirements.txt file +-b--bin <bin>              console_script/script to invoke +-y--yes                    respond yes to all prompts + + + + diff --git a/scripts/generate-svgs.py b/scripts/generate-svgs.py index 5f33d4a..43c2aaf 100755 --- a/scripts/generate-svgs.py +++ b/scripts/generate-svgs.py @@ -38,18 +38,9 @@ cli_doc = """ def yartsu(output: Path, args: Tuple[str, str] | str) -> None: if isinstance(args, str): args = (args,) - cmd = [ - "viv", - *args, - "--help", - "|", - "yartsu", - "-w", - "70", - "-o", - str(output), - ] - run(" ".join(cmd), shell=True) + viv_cmd = " ".join(("viv", *args, "--help")) + cmd = f"{viv_cmd} | yartsu -w 70 -t '{viv_cmd}' -o {output}" + run(cmd, shell=True) if not SAVE_PATH.is_dir(): diff --git a/src/viv/viv.py b/src/viv/viv.py index 730a242..11beff0 100755 --- a/src/viv/viv.py +++ b/src/viv/viv.py @@ -55,7 +55,7 @@ from typing import ( from urllib.error import HTTPError from urllib.request import urlopen -__version__ = "23.8a3-11-g6b48e8c-dev" +__version__ = "23.8a3-15-gfaca36d-dev" class Spinner: @@ -188,7 +188,7 @@ class Ansi: self.option: str = self.yellow self.metavar: str = "\033[33m" # normal yellow - if Env().no_color or not sys.stderr.isatty(): + if not Env().force_color and (Env().no_color or not sys.stderr.isatty()): for attr in self.__dict__: setattr(self, attr, "")