summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-29 10:01:35 +0300
committerPaul Buetow <paul@buetow.org>2026-05-29 10:01:35 +0300
commit89f34ab3c4b139ec7ac7cae80fe288b94e8f600f (patch)
treef3b282c72c33f28f67a773afec4c55975cc0c025
parent90e3fc07894c754364809c4733e403bf4fdeb484 (diff)
docs(cli): replace legacy flag examples with cobra subcommands (rq)
-rw-r--r--doc/README.md4
-rw-r--r--doc/api-reference.md8
-rw-r--r--doc/configuration.md24
-rw-r--r--doc/development.md4
-rw-r--r--doc/examples.md83
5 files changed, 62 insertions, 61 deletions
diff --git a/doc/README.md b/doc/README.md
index 02ea0f0..1391062 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -29,6 +29,6 @@ GitSyncer is a tool for synchronizing Git repositories across multiple platforms
1. Install GitSyncer
2. Create a configuration file
-3. Run `gitsyncer --sync-all` to sync all configured repositories
+3. Run `gitsyncer sync all` to sync all configured repositories
-See the [Configuration Guide](configuration.md) for detailed setup instructions. \ No newline at end of file
+See the [Configuration Guide](configuration.md) for detailed setup instructions.
diff --git a/doc/api-reference.md b/doc/api-reference.md
index b7ed2f8..7ad41b1 100644
--- a/doc/api-reference.md
+++ b/doc/api-reference.md
@@ -73,16 +73,16 @@ Lists all configured organizations from config.
Lists all configured repositories from config.
#### func HandleSync(cfg *config.Config, flags *Flags) int
-Synchronizes a single repository specified by `--sync` flag.
+Synchronizes a single repository, used by `gitsyncer sync repo [name]`.
#### func HandleSyncAll(cfg *config.Config, flags *Flags) int
-Synchronizes all repositories listed in configuration.
+Synchronizes all repositories listed in configuration, used by `gitsyncer sync all`.
#### func HandleSyncCodebergPublic(cfg *config.Config, flags *Flags) int
-Discovers and syncs all public Codeberg repositories to other platforms.
+Discovers and syncs all public Codeberg repositories to other platforms, used by `gitsyncer sync codeberg-to-github`.
#### func HandleSyncGitHubPublic(cfg *config.Config, flags *Flags) int
-Discovers and syncs all public GitHub repositories to other platforms.
+Discovers and syncs all public GitHub repositories to other platforms, used by `gitsyncer sync github-to-codeberg`.
### Helper Functions (sync_handlers.go)
diff --git a/doc/configuration.md b/doc/configuration.md
index 230cac6..922d089 100644
--- a/doc/configuration.md
+++ b/doc/configuration.md
@@ -63,7 +63,7 @@ Array of organization objects. At least one organization must be configured.
- Can also be set via environment variable or file
#### repositories (optional)
-Array of repository names to sync. If empty, use `--sync-codeberg-public` or `--sync-github-public` to discover repositories.
+Array of repository names to sync. If empty, use `gitsyncer sync codeberg-to-github` or `gitsyncer sync github-to-codeberg` to discover repositories.
#### exclude_branches (optional)
Array of regex patterns for branches to exclude from synchronization.
@@ -174,7 +174,7 @@ Sync between GitHub and Codeberg:
## GitHub Token Configuration
GitHub tokens are required for:
-- Creating repositories (`--create-github-repos`)
+- Creating repositories (`sync ... --create-repos`)
- Listing private repositories
- Higher API rate limits
@@ -211,7 +211,7 @@ GitHub tokens are required for:
#### Method 2: Environment Variable
```bash
export GITHUB_TOKEN="ghp_xxxxxxxxxxxx"
-gitsyncer --sync-all
+gitsyncer sync all
```
#### Method 3: Token File
@@ -223,13 +223,13 @@ chmod 600 ~/.gitsyncer_github_token
### Testing Token
```bash
-gitsyncer --test-github-token
+gitsyncer test github-token
```
## Codeberg Token Configuration
Codeberg tokens are required for:
-- Creating repositories (`--create-codeberg-repos`)
+- Creating repositories (`sync ... --create-repos`)
- Listing private repositories
### Token Sources (in order of precedence)
@@ -264,7 +264,7 @@ Codeberg tokens are required for:
#### Method 2: Environment Variable
```bash
export CODEBERG_TOKEN="xxxxxxxxxxxx"
-gitsyncer --sync-all
+gitsyncer sync all
```
#### Method 3: Token File
@@ -289,7 +289,7 @@ The `exclude_branches` field accepts regular expressions to filter out branches
To see which branches are excluded:
```bash
-gitsyncer --sync repo-name
+gitsyncer sync repo repo-name
# Output will show excluded branches and patterns
```
@@ -301,7 +301,7 @@ Begin with a minimal configuration and add complexity as needed.
### 2. Use Dry Run
Test your configuration with `--dry-run` before actual synchronization:
```bash
-gitsyncer --sync-all --dry-run
+gitsyncer sync all --dry-run
```
### 3. Secure Your Tokens
@@ -322,7 +322,7 @@ gitsyncer --sync-all --dry-run
### Configuration Not Found
```bash
-$ gitsyncer --sync myrepo
+$ gitsyncer sync repo myrepo
No configuration file found. Please create one of:
- ./gitsyncer.json
- /home/user/.config/gitsyncer/config.json
@@ -333,7 +333,7 @@ No configuration file found. Please create one of:
### Invalid JSON
```bash
-$ gitsyncer --list-orgs
+$ gitsyncer list orgs
Failed to load configuration: invalid character '}' looking for beginning of object key string
```
@@ -341,7 +341,7 @@ Failed to load configuration: invalid character '}' looking for beginning of obj
### No Organizations Configured
```bash
-$ gitsyncer --sync myrepo
+$ gitsyncer sync repo myrepo
Configuration must have at least one organization
```
@@ -349,7 +349,7 @@ Configuration must have at least one organization
### Token Issues
```bash
-$ gitsyncer --test-github-token
+$ gitsyncer test github-token
ERROR: Token test failed: authentication failed (401)
```
diff --git a/doc/development.md b/doc/development.md
index 0d80958..9aa7454 100644
--- a/doc/development.md
+++ b/doc/development.md
@@ -351,7 +351,7 @@ test: add integration tests for branch filtering
cd test && ./run_integration_tests.sh
# Test manually
- ./gitsyncer --sync test-repo
+ ./gitsyncer sync repo test-repo
```
2. **Format code**:
@@ -414,7 +414,7 @@ func (s *Syncer) debugOperation() {
Use:
```bash
-GITSYNCER_DEBUG=1 gitsyncer --sync test-repo
+GITSYNCER_DEBUG=1 gitsyncer sync repo test-repo
```
### Common Issues
diff --git a/doc/examples.md b/doc/examples.md
index 4f8dba4..7d01fd8 100644
--- a/doc/examples.md
+++ b/doc/examples.md
@@ -16,36 +16,36 @@ This guide provides practical examples of using GitSyncer for various scenarios.
```bash
# Sync a specific repository
-gitsyncer --sync my-project
+gitsyncer sync repo my-project
# Sync with custom working directory
-gitsyncer --sync my-project --work-dir /tmp/gitsyncer-work
+gitsyncer sync repo my-project --work-dir /tmp/gitsyncer-work
# Dry run to preview changes
-gitsyncer --sync my-project --dry-run
+gitsyncer sync repo my-project --dry-run
```
### Sync All Configured Repositories
```bash
# Sync all repositories in config
-gitsyncer --sync-all
+gitsyncer sync all
-# Create missing GitHub repos automatically
-gitsyncer --sync-all --create-github-repos
+# Create missing repositories automatically
+gitsyncer sync all --create-repos
```
### List Operations
```bash
# List configured organizations
-gitsyncer --list-orgs
+gitsyncer list orgs
# List configured repositories
-gitsyncer --list-repos
+gitsyncer list repos
# Show version
-gitsyncer --version
+gitsyncer version
```
## Repository Discovery
@@ -54,33 +54,34 @@ gitsyncer --version
```bash
# Discover and sync all public repos from Codeberg
-gitsyncer --sync-codeberg-public
+gitsyncer sync codeberg-to-github
# Also create repos on GitHub if they don't exist
-gitsyncer --sync-codeberg-public --create-github-repos
+gitsyncer sync codeberg-to-github --create-repos
# Dry run to see what would be synced
-gitsyncer --sync-codeberg-public --dry-run
+gitsyncer sync codeberg-to-github --dry-run
```
### Sync All Public GitHub Repositories to Codeberg
```bash
# Discover and sync all public repos from GitHub
-gitsyncer --sync-github-public
+gitsyncer sync github-to-codeberg
-# Note: Codeberg repos must already exist
-gitsyncer --sync-github-public
+# Also create missing repositories automatically
+gitsyncer sync github-to-codeberg --create-repos
```
### Full Bidirectional Sync
```bash
# Sync all public repos in both directions
-gitsyncer --full
+gitsyncer sync bidirectional
# Equivalent to:
-# gitsyncer --sync-codeberg-public --sync-github-public --create-github-repos
+# gitsyncer sync codeberg-to-github --create-repos
+# gitsyncer sync github-to-codeberg --create-repos
```
## Advanced Synchronization
@@ -105,7 +106,7 @@ Configuration with branch exclusions:
Output shows excluded branches:
```bash
-$ gitsyncer --sync my-project
+$ gitsyncer sync repo my-project
🚫 Excluded 3 branches based on patterns:
Patterns: '^temp-', '^feature/experimental-', '-wip$'
@@ -119,7 +120,7 @@ $ gitsyncer --sync my-project
When conflicts occur:
```bash
-$ gitsyncer --sync my-project
+$ gitsyncer sync repo my-project
ERROR: repository has unresolved merge conflicts
Please resolve conflicts in: /home/user/.gitsyncer-work/my-project
@@ -135,18 +136,18 @@ git status
git add .
git commit -m "Resolved conflicts"
cd -
-gitsyncer --sync my-project
+gitsyncer sync repo my-project
# Option 2: Start fresh
rm -rf /home/user/.gitsyncer-work/my-project
-gitsyncer --sync my-project
+gitsyncer sync repo my-project
```
### Abandoned Branch Detection
GitSyncer detects branches inactive for 6+ months:
```bash
-$ gitsyncer --sync-all
+$ gitsyncer sync all
[1/3] Syncing project1...
Repository project1 synchronized successfully!
@@ -172,10 +173,10 @@ Repository: project1
```bash
# Add to crontab (crontab -e)
# Sync all repos every 6 hours
-0 */6 * * * /usr/local/bin/gitsyncer --sync-all --config /home/user/.gitsyncer.json >> /var/log/gitsyncer.log 2>&1
+0 */6 * * * /usr/local/bin/gitsyncer sync all --config /home/user/.gitsyncer.json >> /var/log/gitsyncer.log 2>&1
# Sync public repos daily at 2 AM
-0 2 * * * /usr/local/bin/gitsyncer --full >> /var/log/gitsyncer-public.log 2>&1
+0 2 * * * /usr/local/bin/gitsyncer sync bidirectional >> /var/log/gitsyncer-public.log 2>&1
```
### Shell Script Wrapper
@@ -192,13 +193,13 @@ LOG_FILE="$HOME/.gitsyncer/sync.log"
echo "Starting sync at $(date)" >> "$LOG_FILE"
# Test GitHub token first
-if ! gitsyncer --test-github-token; then
+if ! gitsyncer test github-token; then
echo "GitHub token test failed" >> "$LOG_FILE"
exit 1
fi
# Sync all repos
-if gitsyncer --sync-all --config "$CONFIG_FILE" >> "$LOG_FILE" 2>&1; then
+if gitsyncer sync all --config "$CONFIG_FILE" >> "$LOG_FILE" 2>&1; then
echo "Sync completed successfully at $(date)" >> "$LOG_FILE"
else
echo "Sync failed at $(date)" >> "$LOG_FILE"
@@ -243,7 +244,7 @@ jobs:
- name: Sync repositories
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: gitsyncer --sync-all --create-github-repos
+ run: gitsyncer sync all --create-repos
```
## Troubleshooting Scenarios
@@ -252,7 +253,7 @@ jobs:
```bash
# Test token is valid
-$ gitsyncer --test-github-token
+$ gitsyncer test github-token
Testing GitHub token authentication...
Loaded token from env var (length: 40)
Checking URL: https://api.github.com/repos/myorg/gitsyncer
@@ -279,7 +280,7 @@ git reflog
### Repository Not Found
```bash
-$ gitsyncer --sync nonexistent-repo
+$ gitsyncer sync repo nonexistent-repo
ERROR: Failed to clone from any organization
```
@@ -292,34 +293,34 @@ Solutions:
```bash
# Permission denied
-$ gitsyncer --sync my-project --work-dir /root/work
+$ gitsyncer sync repo my-project --work-dir /root/work
ERROR: failed to create work directory: permission denied
# Solution: Use accessible directory
-gitsyncer --sync my-project --work-dir ~/gitsyncer-work
+gitsyncer sync repo my-project --work-dir ~/gitsyncer-work
# Disk space issues
-$ gitsyncer --sync large-repo
+$ gitsyncer sync repo large-repo
ERROR: write error: no space left on device
# Solution: Clean up or use different disk
df -h
rm -rf ~/.gitsyncer-work/old-repo
-gitsyncer --sync large-repo --work-dir /mnt/storage/gitsyncer
+gitsyncer sync repo large-repo --work-dir /mnt/storage/gitsyncer
```
### Network and Connectivity
```bash
# SSH key issues
-$ gitsyncer --sync my-project
+$ gitsyncer sync repo my-project
ERROR: git@github.com: Permission denied (publickey)
# Solution: Add SSH key to agent
ssh-add ~/.ssh/id_rsa
# Firewall/proxy issues
-$ gitsyncer --sync my-project
+$ gitsyncer sync repo my-project
ERROR: Failed to connect to github.com port 22: Connection timed out
# Solution: Use HTTPS URLs in config
@@ -336,20 +337,20 @@ ERROR: Failed to connect to github.com port 22: Connection timed out
### 1. Start with Dry Run
Always test with `--dry-run` first:
```bash
-gitsyncer --sync-all --dry-run
+gitsyncer sync all --dry-run
```
### 2. Use Specific Working Directories
Organize syncs by project or purpose:
```bash
-gitsyncer --sync personal-projects --work-dir ~/sync/personal
-gitsyncer --sync work-projects --work-dir ~/sync/work
+gitsyncer sync repo personal-projects --work-dir ~/sync/personal
+gitsyncer sync repo work-projects --work-dir ~/sync/work
```
### 3. Monitor Sync Operations
Keep logs for troubleshooting:
```bash
-gitsyncer --sync-all 2>&1 | tee -a ~/gitsyncer.log
+gitsyncer sync all 2>&1 | tee -a ~/gitsyncer.log
```
### 4. Regular Maintenance
@@ -369,5 +370,5 @@ gitsyncer --config config-with-token.json
# Good
export GITHUB_TOKEN="$(pass show github/token)"
-gitsyncer --sync-all
-``` \ No newline at end of file
+gitsyncer sync all
+```