mani CLI

website·Indexed 32 days ago

https://manicli.com/

A command-line interface tool for managing multiple repositories, designed for microservices and multi-project environments. It provides capabilities for syncing, listing, and describing projects, as well as running tasks across specific projects or those matching certain tags and paths via a mani.yaml configuration.

Tokens
9.1K
Snippets
63
Records
79
Agent score
63%

What's inside mani

  1. Overview of mani CLI for multi-repository management

    mani is a single-binary CLI tool designed to manage multiple repositories from a central location. It allows users to maintain a list of repositories (including names, URLs, and descriptions), clone all repositories with a single command, and execute ad-hoc or custom commands across one, a subset, or all managed repositories.
  2. Overview of mani CLI for multi-repository management

    mani is a portable, dependency-free CLI tool designed for managing multiple repositories simultaneously. It is particularly useful for microservices, multi-project systems, or collections of libraries. Key capabilities include declarative configuration, bulk cloning, running ad-hoc or custom commands across repositories, a built-in TUI, flexible filtering, and auto-completion support.
  3. Understand mani.yaml configuration concepts

    The mani.yaml configuration file is organized around several core concepts that define how projects are managed and how tasks are executed:

    • projects: Directories (often git repositories with an associated URL attribute).
    • tasks: Shell commands designed to be run against selected projects.
    • specs: Configurations that modify the execution and output of tasks.
    • targets: Shorthand filters used to select specific projects when running tasks.
    • themes: Configurations used to customize the visual output of mani commands.
    • env: Environment variables defined at global, project, or task levels.

    Note: Specs, targets, and themes utilize a default object that can be overridden by the user to customize mani command behavior.

  4. Run and describe tasks with Mani CLI

    Mani provides several commands for interacting with defined tasks and projects:

    • describe: Displays detailed information about commands and projects.
    • run: Executes a task. Use the --describe flag to suppress command information during execution.
    • exec: Runs an arbitrary command.
    • tree: Lists the contents of projects in a tree-like format.
    • list: Lists projects and tags, with support for filtering by tags and projects.
  5. Describe tasks using mani describe tasks

    Use the describe tasks command to list all available tasks or get details about a specific task. It also provides an option to edit the task configuration.
    # Describe all tasks
    mani describe tasks
    
    # Describe a specific task
    mani describe task <task>
  6. Filter projects using complex tag expressions

    The tags_expr filter allows boolean operations to determine project inclusion.

    Operator Precedence:

    1. () : Grouping
    2. ! : NOT (logical negation)
    3. && : AND (logical conjunction)
    4. || : OR (logical disjunction)

    Tag Constraints: Tags cannot contain whitespace or reserved characters ((, ), !, &, |). Valid tags can include letters, numbers, hyphens, underscores, dots, and symbols like @, #, and $. (e.g., my-tag, v1.0, @scope/package).

    # Example expression: (main && (dev || prod)) && !test
    # This requires projects to:
    # 1. Have the "main" tag
    # 2. Have either the "dev" OR "prod" tag
    # 3. NOT have the "test" tag
  7. Create parameterized tasks in mani

    You can create tasks that accept parameters by defining them in the env section of a task. These parameters can be passed via the CLI during execution. To wrap a parameterized task with fixed values, create a new task that defines the env and lists the parameterized task under commands. Note: Do not use cmd: mani run <task> inside a wrapping task, as it spawns a new process that will not inherit the wrapping task's environment or target.
    tasks:
      # Parameterized task
      checkout:
        desc: switch repositories to the given branch
        env:
          branch: ''
        cmd: |
          [ -z "$branch" ] && echo "❌ A branch name is required" && exit 1
          if git show-ref --verify --quiet "refs/heads/$branch"; then
            git switch "$branch"
          else
            git switch -c "$branch"
          fi
    
      # Wrapping task with fixed branch and target
      checkout-feature-shopping:
        desc: switch frontend repositories to the shopping feature branch
        spec: custom
        env:
          branch: shopping
        target:
          tags: [frontend]
        commands:
          - task: checkout

    CLI Usage:

    mani run checkout branch=master -t frontend

  8. Manage Git worktrees in mani projects

    Mani supports Git worktrees for projects. Worktrees can be defined in the project configuration using a required path and an optional branch (which defaults to the path's basename if not provided). Worktrees may reside inside or outside the parent project directory.

    • mani init: Automatically discovers existing worktrees using git worktree list.
    • mani sync: Creates worktrees defined in the configuration.
    • mani list projects: Supports a worktree column option to display worktree information.
    # Example project config snippet
    projects:
      - name: my-project
        worktrees:
          - path: ./worktrees/feature-x
            branch: feature-x
  9. Build mani from source

    To build the mani CLI, ensure you have Go 1.25 or above and GoReleaser installed. Use the following make commands based on your target:
    # Build mani for your current platform target
    make build
    
    # Build mani binaries and archives for all platforms using goreleaser
    make build-all
  10. Install mani CLI via package managers

    mani is available for Linux and macOS (with partial support for Windows). It can be installed using several common package managers or direct download methods.
    # via cURL (Linux & macOS)
    curl -sfL https://raw.githubusercontent.com/alajmo/mani/main/install.sh | sh
    
    # via Homebrew
    brew tap alajmo/mani
    brew install mani
    
    # via MacPorts
    sudo port install mani
    
    # via Arch Linux
    pacman -S mani
    
    # via Nix
    nix-env -iA nixos.mani
    
    # via Go
    go get -u github.com/alajmo/mani
  11. Initialize Mani in a project directory

    Run mani init inside a directory containing your git repositories to set up Mani. By default, this command performs two actions:

    1. Generates a mani.yaml file containing projects and custom tasks. Any subdirectory containing a .git directory is automatically included unless the --auto-discovery=false flag is used.
    2. Generates or updates a .gitignore file (if the current directory is a git repo) to include the projects specified in mani.yaml. Use mani init --sync-gitignore=false to opt out of this behavior.
    mani init
  12. Locate and override mani configuration files

    When executing a command, mani searches the current directory and all parent directories for mani.yaml, mani.yml, .mani.yaml, or .mani.yml.

    It also imports a user config file from the following platform-specific locations:

    • Linux: $XDG_CONFIG_HOME/mani/config.yaml or $HOME/.config/mani/config.yaml
    • Darwin (macOS): $HOME/Library/Application Support/mani/config.yaml
    • Windows: %AppData%\mani