Skip to main content

No project description provided

Project description

Motivation

Alfred is an extensible building tool that can replace a Makefile or Fabric. Writing commands in python is done in a few minutes, even in the case of a mono-repository which contains several products.

In this dev, we are eating our own dog food. We are using alfred for the continuous integration process of itself instead of Makefile as I usually do.

# run the continuous integration process
alfred ci

# publish the package on pypi
alfred twine

ci

Getting started

To configure a python project to use alfred, here is the procedure:

pip3 install alfred-cli
alfred init

A hello_world command was created for the example:

alfred hello_world --name "Fabien"

A file .alfred.yml will be initialized at the root of the repository.

Behind the scene

Alfred rely heavily on click and plumblum :

Why using alfred instead of Makefile or Bash scripts

One of the advantages of bash and Makefile is their native presence in many environments. By default, a Makefile allows you to segment these commands efficiently. Autocompletion is first-citizen feature. Alfred doesn't have it yet.

Alfred allows you to create more complex commands than with Make. From the start, you benefit from a formatted documentation for each of your orders. It is easy to create one command per file thanks to auto discovery. You can see an implementation in this repository in alfred_cmd/.

Thanks to the power of Click, it's easy to add options to your commands. They allow for example to implement flags for your CI process which offer you an execution for the frontend.

Alfred allows you to mix shell code with python instructions. In some cases, it allows you to perform efficient processing on API calls. You can use either the cli (for git, ...) or pythons libraries depending on the nature of the treatment you want to perform.

In our development process, we frequently need to operate on application with several process (frontend in react, server in flask, two external service in flask). To mount those process, we use honcho with alfred to load Procfile that will manage those process.

Why not using alfred

If you want to create a cli you will distribute, alfred is not designed for that. I won't recommand as well to use it to build a data application even if you can use python and many library.

Alfred command can import only installed library. You can't use relative import. That makes difficult to share code between your commands.

The latest version

You can find the latest version to ...

git clone https://github.com/FabienArcellier/pyalfred.git

Developper guideline

pipenv install
pipenv shell
$ alfred

Usage: alfred [OPTIONS] COMMAND [ARGS]...

  alfred is a building tool to make engineering tasks easier to develop and to
  maintain

Options:
  --help  Show this message and exit.

Commands:
  ci                 execute continuous integration process of alfred
  dist               build distributions for alfred in dist/
  lint               validate alfred using pylint on the package alfred
  tests              validate alfred with all the automatic testing
  tests:acceptances  validate alfred with acceptances testing
  tests:units        validate alfred with unit testing
  twine              push the package to pypi

Install development environment

Use make to instanciate a python virtual environment in ./venv and install the python dependencies.

pipenv install --dev

Install production environment

pipenv install

Initiate or update the library requirements

If you want to initiate or update all the requirements install_requires declared in setup.py and freeze a new Pipfile.lock, use this command

pipenv update

Activate the python environment

When you setup the requirements, a venv directory on python 3 is created. To activate the venv, you have to execute :

pipenv shell

Run the linter and the unit tests

Before commit or send a pull request, you have to execute pylint to check the syntax of your code and run the unit tests to validate the behavior.

alfred ci

Contributors

  • Fabien Arcellier

License

MIT License

Copyright (c) 2021 Fabien Arcellier

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alfred-cli-1.0.12.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alfred_cli-1.0.12-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file alfred-cli-1.0.12.tar.gz.

File metadata

  • Download URL: alfred-cli-1.0.12.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for alfred-cli-1.0.12.tar.gz
Algorithm Hash digest
SHA256 e69158568b0f6d390cd7b9a0a653e8140eca56dd9db474eea0313e6ed66d9df5
MD5 0f45fb18ce9780a6faa8466a793e28ac
BLAKE2b-256 109fc53a154cc692e86ca46c62fa6c0c411754b9ccbc8bbe82e704874a5fb585

See more details on using hashes here.

File details

Details for the file alfred_cli-1.0.12-py3-none-any.whl.

File metadata

  • Download URL: alfred_cli-1.0.12-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for alfred_cli-1.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 5cc8ca90048b83916b5146ace1f54f8491a700df5a41b6dfe7f721b4341a861f
MD5 f779513c9c24daba37c40a05aace5771
BLAKE2b-256 12f1951c16a528cdc00560638c8cdee53e0e6510dfc99c7b20f31efd00e57c32

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page