# resulgit

A powerful command-line interface (CLI) tool for version control system operations.

## Installation

```bash
npm install -g resulgit
```

Or install locally:

```bash
npm install resulgit
```

## Usage

```bash
resulgit <command> [options]
```

## Commands

### Authentication

- `resulgit auth set-token --token <token>` - Set authentication token
- `resulgit auth set-server --server <url>` - Set server URL
- `resulgit auth login --email <email> --password <password>` - Login to server
- `resulgit auth register --username <name> --email <email> --password <password>` - Register new account

### Repository Management

- `resulgit repo list` - List all repositories
- `resulgit repo create --name <name> [--description <text>] [--visibility <private|public>]` - Create new repository
- `resulgit repo log --repo <id> [--branch <name>]` - View commit log
- `resulgit repo head --repo <id> [--branch <name>]` - Get HEAD commit
- `resulgit repo select` - Interactive repository selection

### Clone & Workspace

- `resulgit clone --repo <id> --branch <name> [--dest <dir>]` - Clone a repository
- `resulgit workspace set-root --path <dir>` - Set workspace root directory

### Branch Operations

- `resulgit branch list` - List all branches
- `resulgit branch create --name <branch> [--base <branch>]` - Create new branch
- `resulgit branch delete --name <branch>` - Delete a branch
- `resulgit switch --branch <name>` - Switch to a branch
- `resulgit checkout --branch <name>` - Checkout a branch

### File Operations

- `resulgit status` - Show working directory status
- `resulgit diff [--path <file>] [--commit <id>]` - Show differences
- `resulgit add <file> [--content <text>] [--all]` - Add files
- `resulgit rm --path <file>` - Remove files
- `resulgit mv --from <old> --to <new>` - Move/rename files
- `resulgit restore --path <file> [--source <commit>]` - Restore file from commit

### Version Control

- `resulgit commit --message <text>` - Create a commit
- `resulgit push` - Push changes to remote
- `resulgit pull` - Pull changes from remote
- `resulgit merge --branch <name> [--squash] [--no-push]` - Merge branches
- `resulgit cherry-pick --commit <id> [--branch <name>] [--no-push]` - Cherry-pick a commit
- `resulgit revert --commit <id> [--no-push]` - Revert a commit
- `resulgit reset [--commit <id>] [--mode <soft|mixed|hard>]` - Reset to commit

### Stash Operations

- `resulgit stash` or `resulgit stash save [--message <msg>]` - Save changes to stash
- `resulgit stash list` - List all stashes
- `resulgit stash pop [--index <n>]` - Apply and remove stash
- `resulgit stash apply [--index <n>]` - Apply stash without removing
- `resulgit stash drop [--index <n>]` - Delete a stash
- `resulgit stash clear` - Clear all stashes

### Tags

- `resulgit tag list` - List all tags
- `resulgit tag create --name <tag> [--branch <name>]` - Create a tag
- `resulgit tag delete --name <tag>` - Delete a tag

### Pull Requests

- `resulgit pr list` - List pull requests
- `resulgit pr create --title <title> [--source <branch>] [--target <branch>]` - Create pull request
- `resulgit pr merge --id <id>` - Merge a pull request

### Information

- `resulgit current` - Show current repository and branch
- `resulgit head` - Show HEAD commit ID
- `resulgit show --commit <id>` - Show commit details

## Global Options

- `--server <url>` - Override default server
- `--token <token>` - Override stored token
- `--json` - Output in JSON format
- `--dir <path>` - Specify working directory

## Examples

```bash
# Login to server
resulgit auth login --email user@example.com --password mypassword

# List repositories
resulgit repo list

# Clone a repository
resulgit clone --repo 123 --branch main

# Check status
resulgit status

# Create and commit changes
resulgit add file.txt --content "Hello World"
resulgit commit --message "Add file.txt"
resulgit push

# Create a branch
resulgit branch create --name feature-branch

# Merge branches
resulgit merge --branch feature-branch
```

## Configuration

Configuration is stored in `~/.resulgit/config.json`. You can set:
- `server`: Default server URL
- `token`: Authentication token
- `workspaceRoot`: Default workspace directory

## License

MIT

