Skip to content

MacPaw/cocoa-tools-cli

Repository files navigation

MacPaw Cocoa Tools CLI (mpct)

A comprehensive Swift CLI toolkit for engineers, providing essential utilities for scripts and secret management.

Overview

mpct is a modular Swift CLI project targeting macOS 15+ that helps engineers with common development tasks through a collection of specialized modules and commands.

πŸš€ Quick Start

Installation

mise

  1. Add mpct to the [tools] section in your mise.toml

    [tools]
    "ubi:MacPaw/cocoa-tools-cli" = { version = "latest", exe = "mpct" }
  2. Run mise install.

πŸ›  Commands

Command Structure

mpct
β”œβ”€β”€ envsubst              # Environment variable substitution
└── secrets               # Secret management commands
    β”œβ”€β”€ export            # Export secrets from providers
    └── obfuscate         # Generate obfuscated Swift code

Environment variable substitution command.

mpct envsubst --input template.txt --output config.txt

Key Features:

  • Shell-compatible variable expansion
  • Support for default values and error handling
  • Stdin/stdout processing
  • Strict validation options

Import secrets from various providers.

mpct secrets export --config secrets.yaml --source op --destination mise

Key Features:

  • 1Password CLI integration
  • HashiCorp Vault integration
  • Multiple export formats (dotenv, mise, stdout)
  • YAML-based configuration
  • Environment variable substitution in configs

Generate obfuscated Swift code for secrets.

mpct secrets obfuscate --swift-confidential-config config.yaml --output Sources/Secrets.swift

Key Features:

  • Swift-confidential integration
  • Environment variable substitution
  • Secret importing integration
  • Build-time code generation

πŸ“¦ Modules

Core Libraries

Shell-compatible environment variable substitution in strings and data.

  • Features: Shell-style variable expansion, default values, error handling
  • Use Cases: Template processing, configuration file generation
  • Example: ${VAR:-default}, ${VAR+alternate}, ${VAR?error}

Comprehensive secret management with support for multiple providers and export destinations.

  • Features: 1Password integration, YAML configuration, batch operations
  • Use Cases: Secret importing, environment file generation, CI/CD integration
  • Example: Import from 1Password to .env files or mise configurations

Swift code generation with obfuscated secret literals using swift-confidential.

  • Features: Swift-confidential integration, environment variable substitution
  • Use Cases: Secure secret storage in mobile apps, build-time secret processing
  • Example: Generate obfuscated Swift accessors for runtime secret access

Comprehensive semantic versioning implementation with compile-time macro support and build tool integration.

  • Features: Semantic Versioning 2.0.0 compliance, compile-time #semanticVersion macro, build plugin for automatic version generation
  • Use Cases: Version management, build automation, CI/CD integration
  • Example: #semanticVersion("1.2.3-beta.1"), automatic .version file processing

Supporting Libraries

Shell

Shell command execution utilities with mise integration.

  • Features: Process execution, mise tool management
  • Use Cases: Build scripts, tool integration

πŸ— Architecture

Modular Design

  • Loose Coupling: Modules can be used independently (w/o CLI execution)
  • Protocol-Based: Extensible through well-defined interfaces
  • Type Safety: Leverages Swift's type system for safety

Module Dependencies Sample

mpct (executable)
β”œβ”€β”€ EnvSubstCommand β†’ EnvSubst
β”œβ”€β”€ ExportSecretsCommand β†’ ExportSecrets -> ImportSecrets, EnvSubst, Shell
└── ObfuscateSecretsCommand β†’ ObfuscateSecrets β†’ EnvSubst, ExportSecrets

πŸ”§ Development

See the docs/DEVELOPMENT.md file.

πŸ“š Documentation

Commands

Modules

πŸ”— Related Projects


Built with ❀️ by the MacPaw Foundation/Terminus Team

About

No description, website, or topics provided.

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published