Package: sentient-switchblade
Unleash Dev Tool Mastery with a Flick of Your WristCreated byJens Roland⚔️ What is Switchblade?Switchblade is a command line tool that lets you install and run dev tools from a central repository, and configure them in a standardised way across all your projects.Try itTo use the includedpython-poetry-basebundle for Python, create a.switchbladefile in your project root:[switchblade]bundle="gh:jensroland/sentient-switchblade/bundles/python-poetry-base"mode="python-poetry"Then, install Switchblade in your project and callswb lintto run the standard Python linters configured in the base bundle:# Install Switchbladepoetryadd-Gdevsentient-switchblade# Run linters from the bundlepoetryrunswblintThat's it! :tada: Switchblade will fetch the bundle from Github, install the tools specified in the bundle, and run them with the configurations specified in the bundle. No need to install or configure anything yourself, and no need to commit any dev tooling to your project repo.Note: The base bundle assumes that your source code lives undersrc/and your tests undertests/, but it is only meant as an example. To specify your own dev tools and tailor them to your needs and project structure, create your own custom bundle (see below).Who is this for?Switchblade was born from the question:"How do I ensure that I'm using the same linting and testing configurations across all of my project repositories?"Are all of your Python repos using the same version ofBlack? Maybe you switched toflake8on your newer repos but never updated the old ones? Sure, maybe it doesn't matter very much if your tooling deviates a little between your personal projects, but how about this: when your company's DevSecOps team updated all the templates to include scans for known vulnerabilities and credential leaks, did you remember to update all of your repos? And if not, how would you even know?To complicate matters, developer tooling is not simply about choosing a particular linter and firing it up. It's also how you configure it -- maximum line lengths, whether to use single or double quotes, what rules to ignore entirely -- as well as which arguments to pass when you invoke it.In an ideal world, dev tooling would not be checked into version control (seriously) but ratherfetched on demand from a centrally managed dev tooling repository, and configured and invoked in exactly the same way in every repo, every time. This would allow for a single source of truth for all dev tooling, and would make it easy to update configurations across all projects.To achieve this however, you would need some kind of small helper tool to abstract away the fetching, configuring and invoking of your centrally curated 'bundles' of dev tools.Switchblade is that tool.Custom bundlesTo create your own custom bundle with the dev tools and configurations you need, simply create a new Github repo and add abundle.tomlfile to it:[bundle]name="my-dev-tool-bundle"mode="python-poetry"schema_version="1.0.0"# Linters[linters]all=["pylint"][linters.pylint]command="pylint src"# Tests[tests]all=["pytest"][tests.pytest]command="pytest -c pyproject.toml tests"# Extensions to pyproject.toml[tool.poetry.group.switchblade]optional=true[tool.poetry.group.switchblade.dependencies]pylint="^2.17.2"pytest="^7.3.1"[tool.pytest.ini_options]pythonpath="src"For each linter you want to add, specify a[linters.<toolname>]section with acommandkey. Thecommandvalue will be invoked by Switchblade when you runswb lint <toolname>.The[linters]section specifies which linters should be invoked (and in which order) when you runswb lintorswb lint all.The same goes for tests: specify a[tests.<toolname>]section with acommandkey, and add the tool to the[tests]section to have it invoked when you runswb testorswb test all.Tool configurationAnything in thebundle.tomlfile under atool.*section will be temporarily added to the project'spyproject.tomlfile under that section. This allows you to add dependencies and configuration options to all your projects without having to manually edit all the individualpyproject.tomlfiles.If you prefer having separate config files, or for tools which do not supportpyproject.tomlconfiguration, simply add any config files you need in the same folder as thebundle.tomlfile. E.g. you might define a.pylintrcin the bundle repo:[MAIN][MESSAGES CONTROL]disable=C0111,  # missing-docstringC0114,  # missing-module-docstringC0115,  # missing-class-docstringC0116,  # missing-function-docstringW0613,  # unused-argumentNow, when you want to use your custom dev tool bundle in a project, simply point to the repo in the project.switchbladefile as in the example above. Swichblade will then fetch and install the tools you specified in the bundle and run them with the configurations you specified.Per-project overridesTo override the bundle configuration for a specific dev tool in one of your project repos, simply check in the tool dependencies and configuration files in the project repo as you normally would - Switchblade will still invoke the dev tool, but it will not overwrite any existing config files or[tool.*]sections in yourpyproject.tomlfile. Be aware that this does not 'extend' the configuration from the bundle, but replaces that tool configuration entirely, so this feature should be used with caution.To override the command or the list of linters to run, add the corresponding sections (e.g.[linters]or[linters.pylint]in the project.switchbladefile. Switchblade will automatically merge (in this case it does extend rather than replace) the bundle config and Switchblade config before invoking any of the tools.PrerequisitesPython 3.7+Currently, you need Python since you install Switchblade with pip. This may change in the future.FeaturesCLI commandswb lintto run lintersCLI commandswb testto run testsProject 'modes' supported: Currently onlypython-poetryis supported, but more will be added soon.DevelopmentInstall dependencies:>poetryinstallRun unit tests with coverage:>poetryrunpytest-cpyproject.toml--cov-report=term--cov=srctestsOr run unit tests on multiple Python versions with tox:>poetryruntox