diff --git a/README.md b/README.md new file mode 100644 index 0000000..7287801 --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +# Coder + +A CLI tool for syncing git repositories between local and remote servers using git bundles. + +This tool is useful when you need to sync code with a remote server that doesn't have direct git remote access (e.g., air-gapped environments, restricted networks). + +## Installation + +```bash +cargo install --path . +``` + +## Usage + +### Sync + +Sync local repository with a git bundle file: + +```bash +coder sync +``` + +This command will: +- Parse branches from the bundle file +- Remove local branches that don't exist in the bundle +- Add new branches from the bundle +- Update all branches with changes from the bundle + +### Push + +Push local repository to a remote server: + +```bash +coder push +``` + +This command will: +1. Create a git bundle from all local branches +2. Transfer the bundle to the remote server via SCP +3. Run `coder sync` on the remote server +4. Clean up temporary files + +### Pull + +Pull repository from a remote server: + +```bash +coder pull +``` + +This command will: +1. Create a git bundle on the remote server +2. Transfer the bundle to local via SCP +3. Run sync locally to update branches +4. Clean up temporary files + +## Shell Completion + +Generate shell completion scripts: + +```bash +coder --generate > shell init script +``` + +## Requirements + +- Git +- SSH/SCP (for push/pull commands) +- `coder` must be installed on the remote server (for push command) diff --git a/src/main.rs b/src/main.rs index a9999ee..861bbb8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,19 +26,36 @@ enum MainError { #[derive(Subcommand)] enum Commands { - /// Sync code with git bundle file + /// Sync local repository with a git bundle file + #[command( + long_about = "Update local branches to match the bundle. Removes branches not in bundle, adds new branches, and updates existing ones." + )] Sync(Sync), - /// Push code to remote server with git bundle file + + /// Push local repository to a remote server + #[command( + long_about = "Create a git bundle from all local branches, transfer it to the remote server via SCP, and run sync on the remote." + )] Push(Push), - /// Pull code from remote server with git bundle file + + /// Pull repository from a remote server + #[command( + long_about = "Create a git bundle on the remote server, transfer it locally via SCP, and sync local branches." + )] Pull(Pull), } #[derive(Parser)] +#[command( + version, + about = "Sync git repositories via bundles over SSH", + long_about = "A CLI tool for syncing git repositories between local and remote servers using git bundles.\nUseful for air-gapped environments or restricted networks without direct git remote access." +)] struct Cli { - /// Generate shell completion + /// Generate shell completion script #[arg(long, value_enum)] generate: Option, + #[command(subcommand)] commands: Option, }