sync

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Copyright (c) 2025 Guilherme Silva Sousa Licensed under the MIT License See LICENSE file in the project root for full license information.

Example

Example demonstrates how to use the sync command

package main

import (
	"fmt"
)

func main() {
	// First, create a ccmd.yaml file with declared dependencies
	// ccmd.yaml:
	// commands:
	//   - repo: owner/tool1
	//     version: v1.0.0
	//   - repo: owner/tool2
	//     version: v2.0.0

	// Run sync command
	// This will:
	// 1. Read ccmd.yaml
	// 2. Compare with installed commands
	// 3. Install missing commands
	// 4. Remove commands not in ccmd.yaml (with confirmation)
	// 5. Update ccmd-lock.yaml

	// Example command line usage:
	fmt.Println("ccmd sync")
	fmt.Println("ccmd sync --dry-run  # Preview changes")
	fmt.Println("ccmd sync --force    # Skip confirmation prompts")
}
Example (DryRun)

Example_dryRun demonstrates using sync with dry-run flag

package main

import (
	"fmt"
	"os"
)

func main() {
	// Set up environment
	os.Setenv("CCMD_DRY_RUN", "true")
	defer os.Unsetenv("CCMD_DRY_RUN")

	// In dry-run mode, sync will:
	// - Show what would be installed
	// - Show what would be removed
	// - Not make any actual changes

	fmt.Println("Running sync in dry-run mode...")
	// Output would show:
	// Sync Analysis:
	//
	// Commands to install:
	//   + owner/tool3@v3.0.0
	//
	// Commands to remove (not in ccmd.yaml):
	//   - tool4
	//
	// Dry run mode - no changes were made
}
Example (Force)

Example_force demonstrates using sync with force flag

package main

import (
	"fmt"
	"os"
)

func main() {
	// Set up environment
	os.Setenv("CCMD_FORCE", "true")
	defer os.Unsetenv("CCMD_FORCE")

	// In force mode, sync will:
	// - Skip confirmation prompts for removals
	// - Proceed with all operations automatically

	fmt.Println("Running sync in force mode...")
	// Output would show:
	// Executing sync...
	//
	// Installing commands...
	// ✓ Installed owner/tool1
	//
	// Removing commands...
	// ✓ Removed tool2
	//
	// Updated ccmd-lock.yaml
	// Sync completed successfully!
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCommand

func NewCommand() *cobra.Command

NewCommand creates a new sync command.

Types

type Result

type Result struct {
	ToInstall []string
	ToRemove  []string
	Errors    []error
}

Result contains the analysis results of what needs to be synced.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL