Skip to content

In order to provide an excellent Developer Experience for both internal Peeksters and external developers, use a CLI to interact with the new Peek App Store Repository APIs.

Notifications You must be signed in to change notification settings

peek-travel/peek-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Peek CLI

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.


Table of Contents


Prerequisites

  1. Python 3.6+

    • Ensure you have Python 3.6 or later installed.
    • Check your Python version:
      python --version
      python3 --version
  2. 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
  3. Virtual Environment Setup

    • Use venv for isolating project dependencies:
      python3 -m venv .venv
      source .venv/bin/activate

Setup Instructions

Clone the Repository

git clone https://github.com/peek-travel/peek-cli.git
cd peek-cli

Install Dependencies

  1. Activate the virtual environment:
    source .venv/bin/activate
  2. Install the required Python libraries:
    pip install -r requirements.txt

Add Environment Variables

  1. Create a .env file in the project directory:
    touch .env
  2. Add server URLs for different environments:
    SANDBOX_URL=http://sandbox.peek.stack
    LOCAL_URL=http://localhost:8000
    PROD_URL=http://prod.peek.stack

Using the CLI

Activate the Virtual Environment

source .venv/bin/activate

Run the CLI

python cli.py --help

Example Commands

  1. Create a Publisher

    python cli.py create-publisher "Martin Bee" [email protected] "https://martin.ext"
  2. List Apps

    python cli.py apps-list

Development and Packaging

Run Tests

Use pytest to run tests for the CLI:

pytest tests/

Bundle the CLI

  1. Generate a Python package:

    python setup.py sdist bdist_wheel
  2. Check the generated distribution files in the dist/ directory.

  3. Test the package installation locally:

    pip install dist/peek_cli-0.1-py3-none-any.whl
    peek --help

Shipping with Homebrew

Step 1: Publish to GitHub

  1. Push the repository to a public GitHub repo.
  2. Tag the release:
    git tag -a v0.1 -m "Initial release"
    git push origin v0.1

Step 2: Generate Homebrew Formula

  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
  2. Test the formula locally:

    brew install --build-from-source ./peek-cli.rb
    peek --help

Step 3: Create a Tap

  1. Create a Homebrew Tap for your repository:
    brew tap peek-travel/peek
  2. Install via the Tap:
    brew install peek-travel/peek/peek-cli

Tips for Updating the CLI

  1. Update the version in setup.py and requirements.txt.
  2. Rebuild the package:
    python setup.py sdist bdist_wheel
  3. 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

About

In order to provide an excellent Developer Experience for both internal Peeksters and external developers, use a CLI to interact with the new Peek App Store Repository APIs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published