A Python-based CLI for interacting with the Peek API. This tool allows you to create publishers, list apps, and perform other actions via an easy-to-use command-line interface.
-
Python 3.6+
- Ensure you have Python 3.6 or later installed.
- Check your Python version:
python --version python3 --version
-
tool-versions
Setup (if applicable)- If you’re managing multiple Python environments, ensure your project’s Python version is set:
asdf local python 3.10.7
- If you’re managing multiple Python environments, ensure your project’s Python version is set:
-
Virtual Environment Setup
- Use
venv
for isolating project dependencies:python3 -m venv .venv source .venv/bin/activate
- Use
git clone https://github.com/peek-travel/peek-cli.git
cd peek-cli
- Activate the virtual environment:
source .venv/bin/activate
- Install the required Python libraries:
pip install -r requirements.txt
- Create a
.env
file in the project directory:touch .env
- Add server URLs for different environments:
SANDBOX_URL=http://sandbox.peek.stack LOCAL_URL=http://localhost:8000 PROD_URL=http://prod.peek.stack
source .venv/bin/activate
python cli.py --help
-
Create a Publisher
python cli.py create-publisher "Martin Bee" [email protected] "https://martin.ext"
-
List Apps
python cli.py apps-list
Use pytest
to run tests for the CLI:
pytest tests/
-
Generate a Python package:
python setup.py sdist bdist_wheel
-
Check the generated distribution files in the
dist/
directory. -
Test the package installation locally:
pip install dist/peek_cli-0.1-py3-none-any.whl peek --help
- Push the repository to a public GitHub repo.
- Tag the release:
git tag -a v0.1 -m "Initial release" git push origin v0.1
-
Create a formula file (
peek-cli.rb
):class PeekCli < Formula desc "CLI for interacting with the Peek API" homepage "https://github.com/peek-travel/peek-cli" url "https://github.com/peek-travel/peek-cli/archive/refs/tags/v0.1.tar.gz" sha256 "CHECKSUM_OF_TARBALL" license "MIT" depends_on "[email protected]" def install virtualenv_install_with_resources end end
-
Test the formula locally:
brew install --build-from-source ./peek-cli.rb peek --help
- Create a Homebrew Tap for your repository:
brew tap peek-travel/peek
- Install via the Tap:
brew install peek-travel/peek/peek-cli
- Update the version in
setup.py
andrequirements.txt
. - Rebuild the package:
python setup.py sdist bdist_wheel
- Push changes and retag the release:
git add . git commit -m "Updated CLI to version 0.2" git tag -a v0.2 -m "Updated version" git push origin v0.2