tkit 0.1.2

A customizable tool manager that works like a package manager with customizable install scripts
Documentation
# TKIT - Customizable Tool Manager

A Rust CLI tool that works like a package manager with customizable install scripts. Similar to `make`, it allows you to define complex installation, removal, and update procedures for any tool through simple YAML configuration.

## Installation

```bash
cargo install tkit
```

Or build from source:

**Linux users**: Install required dependencies first:
```bash
sudo apt update
sudo apt install pkg-config build-essential libssl-dev
```

Then build:
```bash
git clone https://github.com/ThembinkosiThemba/tkit
cd tkit
cargo build --release
sudo cp target/release/tkit /usr/local/bin/
```

## Quick Start

### Interactive Setup

TKIT includes a comprehensive setup wizard that guides you through the initial configuration:

```bash
tkit init
```

The setup wizard will help you:
1. **Add Essential Tools** - Choose from curated tools (git, docker, node, python)
2. **Configure GitHub Sync** - Automatically create repositories or use existing ones
3. **Set Auto-Sync** - Choose between manual or automatic synchronization
4. **Add Custom Tools** - Create your first custom tool configuration

### Manual Setup

If you prefer manual setup:

```bash
# Initialize with example tools
tkit init

# List available tools
tkit list

# Install a tool
tkit install node

# Add a custom tool
tkit add mytool
```

### Reset Configuration

Start fresh by clearing all configuration:

```bash
tkit reset
```

**Warning**: This permanently deletes all tools, settings, and sync configuration.

## Commands

- `tkit install <tool>` - Install a tool using its defined install commands
- `tkit remove <tool>` - Remove a tool using its defined remove commands
- `tkit update <tool>` - Update a tool using its defined update commands
- `tkit run <tool>` - Run a tool using its defined run commands
- `tkit list` - List all available tools and their status
- `tkit add <tool>` - Add a new tool configuration interactively
- `tkit delete <tool>` - Delete a tool configuration
- `tkit examples` - Show examples of tool configurations
- `tkit init` - Interactive setup wizard to initialize configuration
- `tkit reset` - Reset configuration (clear all tools and settings)
- `tkit sync setup <repo>` - Setup GitHub integration for syncing configs
- `tkit sync create-repo <name>` - Create a new GitHub repository
- `tkit sync update-token` - Update GitHub personal access token
- `tkit sync push` - Push local config to GitHub
- `tkit sync pull` - Pull config from GitHub
- `tkit sync status` - Show sync status

## Configuration

Tools are configured in `~/.config/tkit/config.yaml`. Each tool can have:

- **install_commands**: List of commands to install the tool
- **remove_commands**: List of commands to remove the tool
- **update_commands**: List of commands to update the tool
- **run_commands**: List of commands to run the tool
- **description**: Description of the tool

### Example Configuration

```yaml
tools:
  node:
    name: node
    description: Node.js runtime
    install_commands:
      - curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
      - sudo apt-get install -y nodejs
    remove_commands:
      - sudo apt-get remove -y nodejs
    update_commands:
      - sudo apt-get update
      - sudo apt-get upgrade -y nodejs
    run_commands:
      - node --version
      - npm --version
    installed: false

  rust:
    name: rust
    description: Rust programming language
    install_commands:
      - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
      - source ~/.cargo/env
    remove_commands:
      - rustup self uninstall -y
    update_commands:
      - rustup update
    run_commands:
      - rustc --version
      - cargo --version
    installed: false
```

## GitHub Sync

TKIT supports syncing your tool configurations with GitHub for backup and sharing across machines.

### Setup GitHub Integration

1. **Option A: Create repository automatically**
   ```bash
   # Create and configure a new repository
   tkit sync create-repo my-tkit-configs --private
   ```

2. **Option B: Use existing repository**
   ```bash
   # Configure sync with existing repo
   tkit sync setup username/existing-repo --token ghp_xxxxx
   ```

3. **Option C: Manual setup**
   - Create a GitHub repository manually
   - Generate a personal access token with `repo` permissions
   - Configure sync:

```bash
# Setup with token as argument
tkit sync setup username/my-tkit-configs --token ghp_xxxxx

# Or setup interactively (token input hidden)
tkit sync setup username/my-tkit-configs
```

### Sync Commands

```bash
# Push your config to GitHub
tkit sync push

# Pull config from GitHub
tkit sync pull

# Update your GitHub token
tkit sync update-token

# Or provide token directly
tkit sync update-token --token ghp_xxxxx

# Check sync status (includes auto-sync status)
tkit sync status
```

### Auto-Sync Feature

TKIT can automatically sync your configuration to GitHub whenever you make changes:

- **Enabled**: Changes are automatically pushed to GitHub after adding, deleting, installing, or removing tools
- **Disabled**: Manual sync using `tkit sync push`

Auto-sync is configured during the initial setup wizard or can be enabled by editing your configuration file.

### Example Workflow

Setting up a new machine:
```bash
# 1. Initialize tkit
tkit init

# 2. Configure GitHub sync  
tkit sync setup username/my-configs --token ghp_xxxxx

# 3. Pull your existing configuration
tkit sync pull

# 4. Install tools
tkit install docker
tkit install node
```

## Examples Command

Get inspired with curated tool configurations:

```bash
# Show all examples
tkit examples

# Categories include:
# - Development Tools (VS Code, Git, Docker)
# - Programming Languages (Python, Rust, Go, Node.js)
# - Utilities (curl commands, system info)
# - Web Development (nginx, databases)
# - DevOps Tools (kubectl, terraform)
```

## Use Cases

- **Development Environment Setup**: Install language runtimes, databases, tools
- **Server Provisioning**: Automate installation of services and dependencies
- **Personal Tool Management**: Keep track of installed tools and their versions
- **Team Onboarding**: Share consistent installation procedures
- **Cross-Platform Scripts**: Define platform-specific installation commands
- **Configuration Backup**: Sync configs with GitHub for backup and sharing

## Examples

### Adding a Complex Tool

```bash
tkit add kubernetes
# Follow prompts to add install/remove/update/run commands
```

### Adding Custom Tools

You can add any custom tool or command:

```bash
# Add a custom tool for VS Code
tkit add vscode
# Description: Visual Studio Code editor
# Install commands: 
# 1: wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
# 2: sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
# 3: sudo apt-get update && sudo apt-get install code
# Remove commands:
# 1: sudo apt-get remove code
# Update commands:
# 1: sudo apt-get update && sudo apt-get upgrade code
# Run commands:
# 1: code

# Add a utility tool
tkit add curl-example  
# Description: Curl example website
# Run commands:
# 1: curl -s https://httpbin.org/json
```

### Running Tools

```bash
# Run a tool's defined commands
tkit run vscode        # Opens VS Code
tkit run curl-example  # Executes curl command
tkit run docker        # Shows Docker version and running containers
```

### Multi-Step Installation Example

When adding a tool like Docker, you might define:

Install commands:
1. `curl -fsSL https://get.docker.com -o get-docker.sh`
2. `sudo sh get-docker.sh`
3. `sudo usermod -aG docker $USER`
4. `rm get-docker.sh`

Remove commands:
1. `sudo apt-get remove -y docker docker-engine docker.io containerd runc`
2. `sudo rm -rf /var/lib/docker`

Update commands:
1. `sudo apt-get update`
2. `sudo apt-get upgrade -y docker-ce`

## Features

- ✅ Interactive tool addition
- ✅ Command execution tracking
- ✅ Installation status tracking
- ✅ Colored output for better UX
- ✅ Error handling with descriptive messages
- ✅ Cross-platform configuration storage
- ✅ YAML-based configuration
- ✅ Example tools included

## Publishing to crates.io

1. Update version in `Cargo.toml`
2. Build and test: `cargo build --release && cargo test`
3. Publish: `cargo publish`

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request

## License

MIT License - see LICENSE file for details.