Home

tmpl @main - refs - log -
-
https://git.jolheiser.com/tmpl.git
Template automation
tmpl / contrib / tmpl-completions.nu
- raw
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
def _tmpl_env_keys [] {
  ["TMPL_SOURCE", "TMPL_REGISTRY", "TMPL_BRANCH"]
}

def _tmpl_source_list [] {
  ^tmpl source list --json | from json | each { |it| { value: $it.Name, description: $it.URL } }
}

def _tmpl_template_list [] {
  ^tmpl list --json | from json | each { |it| { value: $it.Name, description: (if $it.Path != "" { $it.Path } else { $"($it.Repository)@($it.Branch)" }) } }
}


# Template automation
export extern "tmpl" [
  --registry(-r): string # Registry directory of tmpl (default: ~/.tmpl) [$TMPL_REGISTRY]
  --source(-s): string   # Short-name source to use [$TMPL_SOURCE]
  --help(-h)             # Show help
  --version(-v)          # Show version
]

# Download a template
export extern "tmpl download" [
  repo_url: string     # Repository URL
  name: string         # Local name for template
  --branch(-b): string # Branch to clone (default: "main") [$TMPL_BRANCH]
  --help(-h)           # Show help
]

# Manage tmpl environment variables
export extern "tmpl env" [
  --help(-h)       # Show help
]

# Set a tmpl environment variable
export extern "tmpl env set" [
  key: string@"_tmpl_env_keys" # Env key
  value: string                # Env value
  --help(-h)                   # Show help
]

# Unset a tmpl environment variable
export extern "tmpl env unset" [
  key: string@"_tmpl_env_keys" # Env key
]

# Initialize a blank tmpl template
export extern "tmpl init" [
  --help(-h)       # Show help
]

# List all templates in registry
export extern "tmpl list" [
  --json           # Output in JSON
  --help(-h)       # Show help
]

# Remove a template
export extern "tmpl remove" [
  name: string     # Name of the template to remove
  --help(-h)       #Show help
]

# Restore templates present in the registry, but missing archives
export extern "tmpl restore" [
  --help(-h): # Show help
]

# Save a local template
export extern "tmpl save" [
  path: string     # Path to the local template
  name: string     # Name of the template
  --help(-h)       # Show help
]

# Work with tmpl sources
export extern "tmpl source" [
  --help(-h): # Show help
]

# Add a tmpl source
export extern "tmpl source add" [
  base_url: string # Base URL
  name: string     # Name
  --help(-h)       # Show help
]

# Remove a tmpl source
export extern "tmpl source remove" [
  name: string@"_tmpl_source_list" # Source to remove
  --help(-h)                       # Show help
]

# Test whether a directory is a valid tmpl template
export extern "tmpl test" [
  path?: string    # Path to test (default: ".")
  --help(-h)       # Show help
]

# Update a template
export extern "tmpl update" [
  name: string@"_tmpl_template_list" # Template to update
  --help(-h):                        # Show help
]

# Use a template
export extern "tmpl use" [
  name: string@"_tmpl_template_list" # The template to execute
  dest?: path                       # Destination for the template (default: ".")
  --defaults                        # Use template defaults
  --force                           # Overwrite existing files
  --help(-h)                        # Show help
]