Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ runinfo
_version.py

# Built vendored view
q2cli/assets/view
rachis_cli/assets/view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ vendor-view: all
git submodule update && \
cd q2view && \
npm install --no-save && \
npm run vendor --VENDOR_DIR=../q2cli/assets/view
npm run vendor --VENDOR_DIR=../rachis_cli/assets/view

# install pytest-xdist plugin for the `-n auto` argument.
mystery-stew: all
Expand All @@ -26,16 +26,16 @@ mystery-stew: all
install: vendor-view all
$(PYTHON) -m pip install -v . && \
mkdir -p $(PREFIX)/etc/conda/activate.d && \
cp hooks/50_activate_q2cli_tab_completion.sh $(PREFIX)/etc/conda/activate.d/
cp hooks/50_activate_rachis_cli_tab_completion.sh $(PREFIX)/etc/conda/activate.d/

dev: dev-no-view vendor-view all

dev-no-view: all
pip install -e . && \
mkdir -p $(PREFIX)/etc/conda/activate.d && \
cp hooks/50_activate_q2cli_tab_completion.sh $(PREFIX)/etc/conda/activate.d/
cp hooks/50_activate_rachis_cli_tab_completion.sh $(PREFIX)/etc/conda/activate.d/

clean: distclean
rm -rf ./q2cli/assets
rm -rf ./rachis_cli/assets

distclean: ;
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# q2cli
# rachis-cli

![](https://github.com/qiime2/q2cli/workflows/ci-dev/badge.svg)
![](https://github.com/rachis-org/rachis-cli/workflows/ci-dev/badge.svg)

A [click-based](http://click.pocoo.org/) command line interface for [QIIME
2](https://github.com/qiime2/qiime2).
A [click-based](http://click.pocoo.org/) command line interface for [rachis](https://github.com/rachis-org/rachis).

## Installation and getting help

Visit https://qiime2.org to learn more about q2cli and the QIIME 2 project.
Visit https://qiime2.org to learn more about rachis-cli and the rachis project.

## Enabling tab completion

Expand All @@ -17,7 +16,7 @@ To enable tab completion in Bash, run the following command or add it to your
`.bashrc`/`.bash_profile`:

```bash
source tab-qiime
source tab-rachis
```

### ZSH
Expand All @@ -26,5 +25,5 @@ To enable tab completion in ZSH, run the following commands or add them to your
`.zshrc`:

```bash
autoload -Uz compinit && compinit && autoload bashcompinit && bashcompinit && source tab-qiime
autoload -Uz compinit && compinit && autoload bashcompinit && bashcompinit && source tab-rachis
```
54 changes: 0 additions & 54 deletions bin/tab-qiime

This file was deleted.

97 changes: 97 additions & 0 deletions bin/tab-rachis
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env bash

# Shell completion for every rachis-cli front-end installed in this
# environment (e.g. `rachis`, `qiime`, and `mosh` in a MOSHPIT deployment).
#
# Front-ends advertise themselves through the `rachis.cli_commands` entry
# point group; see `rachis_cli.util.get_cli_command_names`.
#
# This script is intended to be sourced by the conda activation hook, or on
# the command-line/in .bashrc/.bash_profile:
#
# source tab-rachis
#
# NOTE: this file is always sourced, never executed, so its contents must be
# valid in both bash and zsh (the shebang above is decorative).

# The cached completion script's path and the set of front-end command names
# are both fixed for the life of an activation, so they are resolved here once
# in a single interpreter start - rather than on every <tab>. If rachis-cli
# isn't installed, or is an incompatible version, this yields nothing and no
# completion is registered.
_rachis_meta="$(python -c "import rachis_cli.util as u
print(u.get_completion_path())
print('\n'.join(u.get_cli_command_names()))" 2> /dev/null)"

if [ -n "${_rachis_meta}" ]; then
_RACHIS_COMPLETION_PATH="${_rachis_meta%%$'\n'*}"
_rachis_names="${_rachis_meta#*$'\n'}"

# `${var#*<newline>}` yields the string unchanged when it holds no newline,
# which is what a deployment reporting no front-ends looks like: the empty
# trailing line is stripped by the command substitution above.
if [ "${_rachis_names}" = "${_rachis_meta}" ]; then
_rachis_names=""
fi

# Fall back to the front-ends provided by rachis-cli itself if the entry
# point metadata is missing (e.g. an uninstalled source checkout).
if [ -z "${_rachis_names}" ]; then
_rachis_names="rachis"
fi

# NOTE: `_RACHIS_COMPLETION_PATH` is intentionally left set in the shell -
# the completion function below reads it every time it runs.
_rachis_completion()
{
# If the completion script exists, attempt completion by invoking the
# script in a subshell, supplying COMP_WORDS and COMP_CWORD. Capture the
# output as the completion reply. If the completion script failed, don't
# attempt completion.
if [[ -f "${_RACHIS_COMPLETION_PATH}" ]] ; then
COMPREPLY=( $(COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD="${COMP_CWORD}" \
"${_RACHIS_COMPLETION_PATH}" 2> /dev/null) )

if [[ $? != 0 ]]; then
unset COMPREPLY
fi
else
unset COMPREPLY
fi

return 0
}

# Register the completion function against each installed front-end.
#
# NOTE: the iteration is over a command substitution rather than over
# `${_rachis_names}` directly because zsh does not word-split unquoted
# parameter expansions - passing the list as one argument would register a
# single command whose name is the entire list.
_rachis_first=""
for _rachis_cmd in $(printf '%s\n' "${_rachis_names}"); do
# Enable default readline and bash completion behavior when
# `_rachis_completion` doesn't have a reply.
complete -F _rachis_completion -o default -o bashdefault "${_rachis_cmd}"

if [ -z "${_rachis_first}" ]; then
_rachis_first="${_rachis_cmd}"
fi
done

# Execute one of the front-ends (any command will do) so that tab-completion
# will work out-of-the-box (e.g. with a fresh installation of rachis-cli).
# Running a command will create or refresh the cache if necessary, which
# contains the actual completion script.
#
# Ignore stdout to avoid displaying help text to users enabling
# tab-completion. stderr displays the note about cache refreshing, as that
# can take a few moments to complete.
if [ -n "${_rachis_first}" ]; then
"${_rachis_first}" &> /dev/null
fi

unset _rachis_names _rachis_cmd _rachis_first
fi

unset _rachis_meta
14 changes: 7 additions & 7 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package:
name: q2cli
name: rachis-cli
version: {{ PLUGIN_VERSION }}
source:
path: ..
build:
script: make install
entry_points:
- qiime=q2cli.__main__:qiime
- rachis=rachis_cli.__main__:rachis
requirements:
host:
- python {{ python }}
Expand All @@ -18,24 +18,24 @@ requirements:
- python {{ python }}
- setuptools
- click {{ click }}
- qiime2 >={{ qiime2 }}
- rachis >={{ rachis }}
- q2templates >={{ q2templates }}
build:
- python {{ python }}
- setuptools
- versioningit
test:
requires:
- qiime2 >={{ qiime2 }}
- rachis >={{ rachis }}
- q2templates >={{ q2templates }}
- pytest
- pytest-xdist
- q2-mystery-stew
imports:
- q2cli
- rachis_cli
commands:
- Q2CLIDEV=1 QIIMETEST= qiime --help
- Q2CLIDEV=1 QIIMETEST= py.test --pyargs q2cli
- Q2CLIDEV=1 QIIMETEST= rachis --help
- Q2CLIDEV=1 QIIMETEST= py.test --pyargs rachis_cli
about:
home: https://qiime2.org
license: BSD-3-Clause
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if [ -n "${ZSH_VERSION-}" ]; then
autoload -Uz compinit && compinit && autoload bashcompinit && bashcompinit && source tab-qiime
autoload -Uz compinit && compinit && autoload bashcompinit && bashcompinit && source tab-rachis
elif [ -n "${BASH_VERSION-}" ]; then
source tab-qiime
source tab-rachis
fi
21 changes: 12 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "q2cli"
name = "rachis-cli"
authors = [
{ name = "None", email = "developers@qiime2.org" }
]
Expand All @@ -10,13 +10,16 @@ dynamic = ["version"]

[project.urls]
Homepage = "https://qiime2.org"
Repository = "https://github.com/qiime2/q2cli"
Repository = "https://github.com/rachis-org/rachis-cli"

[project.scripts]
"qiime" = "q2cli.__main__:qiime"
"rachis" = "rachis_cli.__main__:rachis"

[project.entry-points.'qiime2.usage_drivers']
"cli" = "q2cli.core.usage:ReplayCLIUsage"
[project.entry-points.'rachis.cli_commands']
"rachis" = "rachis_cli.__main__:rachis"

[project.entry-points.'rachis.usage_drivers']
"cli" = "rachis_cli.core.usage:ReplayCLIUsage"

[build-system]
requires = [
Expand All @@ -40,17 +43,17 @@ dirty = "{base_version}+{distance}.{vcs}{rev}.dirty"
distance-dirty = "{base_version}+{distance}.{vcs}{rev}.dirty"

[tool.versioningit.write]
file = "q2cli/_version.py"
file = "rachis_cli/_version.py"

[tool.setuptools]
include-package-data = true
script-files = [
"bin/tab-qiime"
"bin/tab-rachis"
]

[tool.setuptools.packages.find]
where = ["."]
include = ["q2cli*"]
include = ["rachis_cli*"]

[tool.setuptools.package-data]
q2cli = ["**/*"]
rachis_cli = ["**/*"]
File renamed without changes.
25 changes: 13 additions & 12 deletions q2cli/__main__.py → rachis_cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,41 @@

import click

import q2cli.commands
import rachis_cli.commands


ROOT_COMMAND_HELP = """\
QIIME 2 command-line interface (q2cli)
--------------------------------------
rachis command-line interface (rachis-cli)
------------------------------------------

To get help with QIIME 2, visit https://qiime2.org.
To get help with rachis, visit https://qiime2.org.

To enable tab completion in Bash, run the following command or add it to your \
.bashrc/.bash_profile:

source tab-qiime
source tab-rachis

To enable tab completion in ZSH, run the following commands or add them to \
your .zshrc:

\b
autoload -Uz compinit && compinit
autoload bashcompinit && bashcompinit
source tab-qiime
source tab-rachis

"""


# Entry point for CLI
@click.command(cls=q2cli.commands.RootCommand, invoke_without_command=True,
@click.command(cls=rachis_cli.commands.RootCommand,
invoke_without_command=True,
no_args_is_help=True, help=ROOT_COMMAND_HELP)
@click.version_option(prog_name='q2cli',
message='%(prog)s version %(version)s\nRun `qiime info` '
'for more version details.')
def qiime():
@click.version_option(prog_name='rachis-cli',
message='%(prog)s version %(version)s\nRun `rachis info`'
' for more version details.')
def rachis():
pass


if __name__ == '__main__':
qiime()
rachis()
File renamed without changes.
Loading
Loading