|
| 1 | +# 🖥️ Command Reference |
| 2 | + |
| 3 | +## `usethis init` |
| 4 | + |
| 5 | +Initialize a new Python project with recommended defaults, including: |
| 6 | + |
| 7 | +- a `pyproject.toml` file and relevant configuration, |
| 8 | +- recommended linters, formatters, spellcheckers, and test frameworks (all opt-out), |
| 9 | +- docstring style enforcement (opt-in), |
| 10 | +- the pre-commit framework (opt-in), |
| 11 | +- CI services (opt-in), |
| 12 | +- declared & installed dependencies via `uv add`, and |
| 13 | +- any other relevant directories or tool-bespoke configuration files. |
| 14 | + |
| 15 | +Supported options: |
| 16 | + |
| 17 | +- `--doc` to add recommended documentation tools (default; or `--no-doc` to opt-out) |
| 18 | +- `--format` to add recommended formatters (default; or `--no-format` to opt-out) |
| 19 | +- `--lint` to add recommended linters (default; or `--no-lint` to opt-out) |
| 20 | +- `--spellcheck` to add a recommended spellchecker (default; or `--no-spellcheck` to opt-out) |
| 21 | +- `--test` to add a recommended testing framework (default; or `--no-test` to opt-out) |
| 22 | +- `--pre-commit` to add the pre-commit framework for git hooks (but the default is `--no-pre-commit`) |
| 23 | +- `--ci` to add a CI service configuration |
| 24 | + Possible values: |
| 25 | + - `bitbucket` for [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) |
| 26 | +- `--docstyle` to set a docstring style convention for the project |
| 27 | + Possible values: |
| 28 | + - `numpy` for [NumPy docstring style](https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard) |
| 29 | + - `google` for [Google docstring style](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) |
| 30 | + - `pep257` for [PEP 257 docstring style](https://www.python.org/dev/peps/pep-0257/) |
| 31 | +- `--status` to set the development status of the project. Defaults to `planning`. |
| 32 | + Possible values: |
| 33 | + - `planning` or `1` for "Development Status :: 1 - Planning" |
| 34 | + - `pre-alpha` or `2` for "Development Status :: 2 - Pre-Alpha" |
| 35 | + - `alpha` or `3` for "Development Status :: 3 - Alpha" |
| 36 | + - `beta` or `4` for "Development Status :: 4 - Beta" |
| 37 | + - `production` or `5` for "Development Status :: 5 - Production/Stable" |
| 38 | + - `mature` or `6` for "Development Status :: 6 - Mature" |
| 39 | + - `inactive` or `7` for "Development Status :: 7 - Inactive" |
| 40 | +- `--offline` to disable network access and rely on caches |
| 41 | +- `--quiet` to suppress output |
| 42 | +- `--frozen` to leave the virtual environment and lockfile unchanged (i.e. do not install dependencies, nor update lockfiles) |
| 43 | + |
| 44 | +## `usethis doc` |
| 45 | + |
| 46 | +Add recommended documentation tools to the project (namely, [MkDocs](https://www.mkdocs.org/)), including: |
| 47 | + |
| 48 | +- declared & installed dependencies via `uv add`, |
| 49 | +- relevant `pyproject.toml` configuration, and |
| 50 | +- any other relevant directories or tool-bespoke configuration files. |
| 51 | + |
| 52 | +Note if `pyproject.toml` is not present, it will be created, since this is required for declaring dependencies via `uv add`. |
| 53 | + |
| 54 | +Supported options: |
| 55 | + |
| 56 | +- `--remove` to remove the tool instead of adding it |
| 57 | +- `--how` to only print how to use the tool, with no other side effects |
| 58 | +- `--offline` to disable network access and rely on caches |
| 59 | +- `--frozen` to leave the virtual environment and lockfile unchanged |
| 60 | +- `--quiet` to suppress output |
| 61 | + |
| 62 | +See [`usethis tool`](#usethis-tool) for more information. |
| 63 | + |
| 64 | +## `usethis format` |
| 65 | + |
| 66 | +Add recommended formatters to the project (namely, [Ruff](https://docs.astral.sh/ruff/formatter/) and [pyproject-fmt](https://pyproject-fmt.readthedocs.io/en/latest/)), including: |
| 67 | + |
| 68 | +- declared & installed dependencies via `uv add`, |
| 69 | +- relevant `pyproject.toml` configuration, and |
| 70 | +- any other relevant directories or tool-bespoke configuration files. |
| 71 | + |
| 72 | +Note if `pyproject.toml` is not present, it will be created, since this is required for declaring dependencies via `uv add`. |
| 73 | + |
| 74 | +Supported options: |
| 75 | + |
| 76 | +- `--remove` to remove the tool instead of adding it |
| 77 | +- `--how` to only print how to use the tool, with no other side effects |
| 78 | +- `--offline` to disable network access and rely on caches |
| 79 | +- `--frozen` to leave the virtual environment and lockfile unchanged |
| 80 | +- `--quiet` to suppress output |
| 81 | + |
| 82 | +See [`usethis tool`](#usethis-tool) for more information. |
| 83 | + |
| 84 | +## `usethis lint` |
| 85 | + |
| 86 | +Add recommended linters to the project (namely, [Ruff](https://docs.astral.sh/ruff/linter) and [deptry](https://github.com/fpgmaas/deptry)), including: |
| 87 | + |
| 88 | +- declared & installed dependencies with `uv add`, |
| 89 | +- relevant `pyproject.toml` configuration, and |
| 90 | +- any other relevant directories or tool-bespoke configuration files. |
| 91 | + |
| 92 | +Note if `pyproject.toml` is not present, it will be created, since this is required for declaring dependencies with `uv add`. |
| 93 | + |
| 94 | +Supported options: |
| 95 | + |
| 96 | +- `--remove` to remove the tool instead of adding it |
| 97 | +- `--how` to only print how to use the tool, with no other side effects |
| 98 | +- `--offline` to disable network access and rely on caches |
| 99 | +- `--frozen` to leave the virtual environment and lockfile unchanged |
| 100 | +- `--quiet` to suppress output |
| 101 | + |
| 102 | +See [`usethis tool`](#usethis-tool) for more information. |
| 103 | + |
| 104 | +## `usethis spellcheck` |
| 105 | + |
| 106 | +Add a recommended spellchecker to the project (namely, [codespell](https://github.com/codespell-project/codespell)), including: |
| 107 | + |
| 108 | +- declared & installed dependencies with `uv add`, |
| 109 | +- relevant `pyproject.toml` configuration, and |
| 110 | +- any other relevant directories or tool-bespoke configuration files. |
| 111 | + |
| 112 | +Note if `pyproject.toml` is not present, it will be created, since this is required for declaring dependencies with `uv add`. |
| 113 | + |
| 114 | +Supported options: |
| 115 | + |
| 116 | +- `--remove` to remove the tool instead of adding it |
| 117 | +- `--how` to only print how to use the tool, with no other side effects |
| 118 | +- `--offline` to disable network access and rely on caches |
| 119 | +- `--frozen` to leave the virtual environment and lockfile unchanged |
| 120 | +- `--quiet` to suppress output |
| 121 | + |
| 122 | +See [`usethis tool`](#usethis-tool) for more information. |
| 123 | + |
| 124 | +## `usethis test` |
| 125 | + |
| 126 | +Add a recommended testing framework to the project (namely pytest), including: |
| 127 | + |
| 128 | +- declared & installed dependencies with `uv add`, |
| 129 | +- relevant `pyproject.toml` configuration, and |
| 130 | +- any other relevant directories or tool-bespoke configuration files. |
| 131 | + |
| 132 | +Note if `pyproject.toml` is not present, it will be created, since this is required for declaring dependencies with `uv add`. |
| 133 | + |
| 134 | +Supported options: |
| 135 | + |
| 136 | +- `--remove` to remove the tool instead of adding it |
| 137 | +- `--how` to only print how to use the tool, with no other side effects |
| 138 | +- `--offline` to disable network access and rely on caches |
| 139 | +- `--frozen` to leave the virtual environment and lockfile unchanged |
| 140 | +- `--quiet` to suppress output |
| 141 | + |
| 142 | +See [`usethis tool`](#usethis-tool) for more information. |
| 143 | + |
| 144 | +## `usethis tool` |
| 145 | + |
| 146 | +Add a new tool to a Python project, including: |
| 147 | + |
| 148 | +- declared & installed dependencies with `uv add`, |
| 149 | +- relevant `pyproject.toml` configuration, |
| 150 | +- any other relevant directories or tool-bespoke configuration files, and |
| 151 | +- `.pre-commit-config.yaml` configuration if using `pre-commit`. |
| 152 | + |
| 153 | +Note if `pyproject.toml` is not present, it will be created, since this is required for |
| 154 | +declaring dependencies with `uv add`. |
| 155 | + |
| 156 | +### Code Quality Tools |
| 157 | + |
| 158 | +- `usethis tool codespell` - Use the [codespell spellchecker](https://github.com/codespell-project/codespell): detect common spelling mistakes. |
| 159 | +- `usethis tool deptry` - Use the [deptry linter](https://github.com/fpgmaas/deptry): avoid missing or superfluous dependency declarations. |
| 160 | +- `usethis tool import-linter` - Use [Import Linter](https://import-linter.readthedocs.io/en/stable/): enforce a self-imposed architecture on imports. |
| 161 | +- `usethis tool pre-commit` - Use the [pre-commit](https://github.com/pre-commit/pre-commit) framework to manage and maintain Git hooks. Note that this will also install all the hooks to Git. |
| 162 | +- `usethis tool pyproject-fmt` - Use the [pyproject-fmt linter](https://github.com/tox-dev/pyproject-fmt): opinionated formatting of 'pyproject.toml' files. |
| 163 | +- `usethis tool ruff` - Use [Ruff](https://github.com/astral-sh/ruff): an extremely fast Python linter and code formatter. |
| 164 | + |
| 165 | +### Testing |
| 166 | + |
| 167 | +- `usethis tool coverage.py` - Use [Coverage.py](https://github.com/nedbat/coveragepy): a code coverage measurement tool. |
| 168 | +- `usethis tool pytest` - Use the [pytest](https://github.com/pytest-dev/pytest) testing framework. |
| 169 | + |
| 170 | +### Documentation |
| 171 | + |
| 172 | +- `usethis tool mkdocs` - Use [MkDocs](https://www.mkdocs.org/): Generate project documentation sites with Markdown. |
| 173 | + |
| 174 | +### Configuration Files |
| 175 | + |
| 176 | +- `usethis tool pyproject.toml` - Use a [pyproject.toml](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#writing-your-pyproject-toml) file to configure the project. |
| 177 | +- `usethis tool requirements.txt` - Use a [requirements.txt](https://pip.pypa.io/en/stable/reference/requirements-file-format/) file exported from the uv lockfile. |
| 178 | + |
| 179 | +Supported options: |
| 180 | + |
| 181 | +- `--remove` to remove the tool instead of adding it |
| 182 | +- `--how` to only print how to use the tool, with no other side effects |
| 183 | +- `--offline` to disable network access and rely on caches |
| 184 | +- `--frozen` to leave the virtual environment and lockfile unchanged |
| 185 | +- `--quiet` to suppress output |
| 186 | + |
| 187 | +For `usethis tool ruff`, in addition to the above options, you can also specify: |
| 188 | + |
| 189 | +- `--linter` to add or remove specifically the linter component of Ruff (default; or `--no-linter` to opt-out) |
| 190 | +- `--formatter` to add or remove specifically the formatter component of Ruff (default; or `--no-formatter` to opt-out) |
| 191 | + |
| 192 | +## `usethis ci` |
| 193 | + |
| 194 | +Add Continuous Integration pipelines to the project. |
| 195 | + |
| 196 | +Currently supported platforms: |
| 197 | + |
| 198 | +- `usethis ci bitbcuket` - Use [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines): a CI/CD service for Bitbucket. |
| 199 | + |
| 200 | +Supported options: |
| 201 | + |
| 202 | +- `--remove` to remove the CI configuration instead of adding it |
| 203 | +- `--offline` to disable network access and rely on caches |
| 204 | +- `--quiet` to suppress output |
| 205 | +- `--frozen` to leave the virtual environment and lockfile unchanged (i.e. do not install dependencies, nor update lockfiles) |
| 206 | + |
| 207 | +## `usethis badge` |
| 208 | + |
| 209 | +Add badges to the README file. |
| 210 | + |
| 211 | +Currently supported badges: |
| 212 | + |
| 213 | +- `usethis badge pre-commit` - [](https://github.com/pre-commit/pre-commit) |
| 214 | +- `usethis badge pypi` - [](https://pypi.python.org/pypi/usethis) |
| 215 | +- `usethis badge ruff` - [](https://github.com/astral-sh/ruff) |
| 216 | +- `usethis badge usethis` - [](https://github.com/usethis-python/usethis-python) |
| 217 | +- `usethis badge uv` - [](https://github.com/astral-sh/uv) |
| 218 | + |
| 219 | +Supported options: |
| 220 | + |
| 221 | +- `--show` to show the badge URL instead of adding (or removing) it |
| 222 | +- `--remove` to remove the badge instead of adding it |
| 223 | +- `--offline` to disable network access and rely on caches |
| 224 | +- `--quiet` to suppress output |
| 225 | + |
| 226 | +## `usethis readme` |
| 227 | + |
| 228 | +Add a README.md file to the project. |
| 229 | + |
| 230 | +Supported options: |
| 231 | + |
| 232 | +- `--quiet` to suppress output |
| 233 | +- `--badges` to also add badges to the README.md file |
| 234 | + |
| 235 | +## `usethis author` |
| 236 | + |
| 237 | +Set new author information for the project. |
| 238 | + |
| 239 | +Required options: |
| 240 | + |
| 241 | +- `--name` for the new author's name |
| 242 | + |
| 243 | +Other supported options: |
| 244 | + |
| 245 | +- `--email` to set the author email address |
| 246 | +- `--overwrite` to overwrite all existing author information |
| 247 | +- `--quiet` to suppress output |
| 248 | + |
| 249 | +## `usethis docstyle <style>` |
| 250 | + |
| 251 | +Set a docstring style convention for the project, and [enforce it with Ruff](https://docs.astral.sh/ruff/rules/#pydocstyle-d). |
| 252 | + |
| 253 | +Defaults to the Google docstring style. |
| 254 | + |
| 255 | +Possible style options: |
| 256 | + |
| 257 | +- `numpy` for [NumPy docstring style](https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard) |
| 258 | +- `google` for [Google docstring style](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) |
| 259 | +- `pep257` for [PEP 257 docstring style](https://www.python.org/dev/peps/pep-0257/) |
| 260 | + |
| 261 | +Example: |
| 262 | + |
| 263 | +`usethis docstyle google` |
| 264 | + |
| 265 | +Supported options: |
| 266 | + |
| 267 | +- `--offline` to disable network access and rely on caches |
| 268 | +- `--quiet` to suppress output |
| 269 | +- `--frozen` to leave the virtual environment and lockfile unchanged (i.e. do not install dependencies, nor update lockfiles) |
| 270 | + |
| 271 | +## `usethis rule <rulecode>` |
| 272 | + |
| 273 | +Add (or manage configuration) of Ruff and Deptry rules in `pyproject.toml`. |
| 274 | + |
| 275 | +See [the Ruff documentation](https://docs.astral.sh/ruff/rules/) for a list of available |
| 276 | +rules, and [the Deptry documentation](https://deptry.com/rules-violations/) for a list |
| 277 | +of available rules. |
| 278 | + |
| 279 | +Example: |
| 280 | + |
| 281 | +`usethis rule RUF001` |
| 282 | + |
| 283 | +Supported options: |
| 284 | + |
| 285 | +- `--remove` to remove the rule selection or ignore status. |
| 286 | +- `--ignore` to add the rule to the ignore list (or remove it if --remove is specified). |
| 287 | +- `--offline` to disable network access and rely on caches |
| 288 | +- `--quiet` to suppress output |
| 289 | + |
| 290 | +## `usethis status <status>` |
| 291 | + |
| 292 | +Set the development status of the project via trove classifiers. |
| 293 | + |
| 294 | +Possible values (required): |
| 295 | + |
| 296 | +- `usethis status planning` or `usethis status 1` for "Development Status :: 1 - Planning" |
| 297 | +- `usethis status pre-alpha` or `usethis status 2` for "Development Status :: 2 - Pre-Alpha" |
| 298 | +- `usethis status alpha` or `usethis status 3` for "Development Status :: 3 - Alpha" |
| 299 | +- `usethis status beta` or `usethis status 4` for "Development Status :: 4 - Beta" |
| 300 | +- `usethis status production` or `usethis status 5` for "Development Status :: 5 - Production/Stable" |
| 301 | +- `usethis status mature` or `usethis status 6` for "Development Status :: 6 - Mature" |
| 302 | +- `usethis status inactive` or `usethis status 7` for "Development Status :: 7 - Inactive" |
| 303 | + |
| 304 | +Supported options: |
| 305 | + |
| 306 | +- `--quiet` to suppress output |
| 307 | +- `--badges` to add an associated badge to the README file |
| 308 | + |
| 309 | +## `usethis list` |
| 310 | + |
| 311 | +Display a table of all available tools and their current usage status. |
| 312 | + |
| 313 | +## `usethis version` |
| 314 | + |
| 315 | +Display the current version of usethis. |
| 316 | + |
| 317 | +## `usethis show` |
| 318 | + |
| 319 | +Show a piece of information about the project. |
| 320 | + |
| 321 | +Currently supported subcommands: |
| 322 | + |
| 323 | +- `usethis show name` to show the name of the project. |
| 324 | +- `usethis show sonarqube` to show appropriate contents of a `sonar-projects.properties` file for SonarQube analysis. |
| 325 | + |
| 326 | +## `usethis browse pypi <package>` |
| 327 | + |
| 328 | +Display or open the PyPI landing page associated with another project. |
| 329 | + |
| 330 | +Example: |
| 331 | + |
| 332 | +`usethis browse pypi numpy` |
| 333 | + |
| 334 | +Supported options: |
| 335 | + |
| 336 | +- `--browser` to open the link in the browser automatically. |
0 commit comments