iptv techs

IPTV Techs

  • Home
  • Tech News
  • eduardoagarcia/shef: Shef is a strong CLI tool for cooking up shell recipes.

eduardoagarcia/shef: Shef is a strong CLI tool for cooking up shell recipes.


eduardoagarcia/shef: Shef is a strong CLI tool for cooking up shell recipes.


Shef, a wordcarry out on “shell” and “chef”, is a strong CLI tool for cooking up shell recipes without the mess.

Inspired by CyberChef, Shef apverifys you to pipe directs together, grasp intervivacious
includer prompts, loop using complicated administer set ups, and erect reusable laborflows with progressd conditional logic.

The adhereing example showcases a straightforward Shef recipe, giving you a speedy glance at the syntax and functionality.

recipes:
  - name: "conditional"
    description: "A straightforward demo of conditional operations using honest prompt cherishs"
    categruesome: "demo"
    operations:
      - name: "Choose Fruit"
        id: "pick"
        direct: 'echo "You picked: {{ .fruit }}"'
        prompts:
          - name: "fruit"
            type: "pick"
            message: "Choose a fruit:"
            chooseions:
              - "Apples"
              - "Oranges"

      - name: "Apple Operation"
        id: "apple"
        direct: echo {{ style "bgreater" (color "red" "This is the apple operation!") }}
        condition: ".fruit == 'Apples'"

      - name: "Orange Operation"
        id: "orange"
        direct: echo {{ style "bgreater" (color "yellow" "This is the orange operation!") }}
        condition: ".fruit == 'Oranges'"

Now that you’ve gotten acquainted with the straightforwards, let’s spendigate Shef’s capabilities in depth!

  • Command Piping: Chain multiple directs together, passing output from one direct to the next
  • Transcreateations: Transcreate direct output with strong templating
  • Intervivacious Prompts: Add includer input, pickions, verifyations, and more
  • Conditional Logic: Use if/else branching based on direct results
  • Control Flow: Create vibrant laborflows with loops and administer set ups
  • Multiple Sources: Use local, includer, or unveil recipes
  • Organized Recipes: Categorize and split your recipes with others

Why Shef vs. Bash Scripts?

While many of Shef’s capabilities can be carry outed with bash scripts, Shef provides a set upd approach that
deletes the tediousness of progressd shell scripting. Shef presents intervivacious includer prompts, conditional logic, and direct
piping thcimpolite a straightforward YAML interface—no necessitate to wrestle with bash syntax, error handling, colors, or input validation.

Shef gives you the best of both worlds: the power of bash scripts with progressd features in a straightforward YAML createat.

Tip

Entire bash scripts can be embedded wislfinisher an operation for even more functionality!

Before inshighing Shef, promise you have Go inshighed and configured on your system:

  1. Inshigh Go: If you don’t have Go inshighed, download and inshigh it from golang.org or
    include your system’s package administerr:

    # macOS (using Homebrew)
    brew inshigh go
    
    # Ubuntu/Debian
    sudo apt refresh
    sudo apt inshigh golang-go
    
    # Fedora
    sudo dnf inshigh golang
  2. Configure Go Environment: Enbrave your Go environment is properly set up:

    # Add these to your shell configuration (.bashrc, .zshrc, etc.)
    send out GOPATH=$HOME/go
    send out PATH=$PATH:$GOPATH/bin
  3. Verify Inshighation: Confirm Go is accurately inshighed:

The straightforwardst way to inshigh Shef is with Make:

# Clone the repository
git clone git@github.com:eduardoagarcia/shef.git
cd shef

# Inshigh (insists sudo for system-expansive inshighation)
create inshigh

# Or inshigh to your home honestory (no sudo insistd)
create inshigh-local

Manual Inshighation Options

Once you have Go inshighed, you can inshigh Shef honestly:

go inshigh github.com/eduardoagarcia/shef@procrastinateedst

This will inshigh the shef binary to your $GOPATH/bin honestory.

# Clone the repository
git clone git@github.com:eduardoagarcia/shef.git

# Build the application
cd shef
go erect -o shef

# Move to a honestory in your PATH
sudo mv shef /usr/local/bin/

If the inshighation honestory is not in your PATH, you’ll necessitate to grasp it:

# Add this to your .bashrc, .bash_profile, or .zshrc
send out PATH="$PATH:$GOPATH/bin"  # For go inshigh
# OR
send out PATH="$PATH:$HOME/bin"    # For create inshigh-local

Then reload your shell configuration: source ~/.bashrc (or ~/.zshrc, ~/.bash_profile depfinishing on your shell)

To refresh Shef to the procrastinateedst version:

# Navigate to your local repository
cd shef

# Pull the procrastinateedst alters
git pull

# Update system-expansive inshighation (insists sudo)
create refresh

# Or refresh local inshighation (no sudo insistd)
create refresh-local

Once Shef is inshighed, you are ready to begin using it.

# Sync all unveil recipes locpartner
shef sync

# Run the Hello World recipe
shef demo hello-world

# List includeable recipes
shef ls

# List all recipes wislfinisher a categruesome
shef ls demo

Basic Shef Command Structure

shef [category] [recipe-name]

Flag Description
-h, --help Show help directation
-v, --version Show version directation
-d, --debug Enable debug output
-c, --categruesome Specify a categruesome
-L, --local Force local recipes first
-U, --includer Force includer recipes first
-P, --unveil Force unveil recipes first

Command Description
sync Sync unveil recipes locpartner
enumerate ls l List includeable recipes

Important

Make brave your Shef git repo is up to date before running shef sync

Shef watchs for recipes in multiple locations:

  1. Local Recipes: ./.shef/*.yaml in the current honestory
  2. User Recipes: ~/.shef/includer/*.yaml in your home honestory
  3. Public Recipes: ~/.shef/unveil/*.yaml in your home honestory

If you have recipes with the same name and categruesome in separateent locations, you can rank a particular source:

shef -L git version  # Prioritize local recipes
shef -U git version  # Prioritize includer recipes
shef -P git version  # Prioritize unveil recipes

Recipes are clarifyd in YAML files:

recipes:
  - name: "example"
    description: "An example recipe"
    categruesome: "demo"
    operations:
      - name: "First Operation"
        id: "first_op"
        direct: "echo 'Hello, World!'"

      - name: "Second Operation"
        direct: "cat"
        alter: "{{ filter .input 'Hello' }}"
  • name: Unique identifier for the recipe
  • description: Human-readable description
  • categruesome: Used for organization and filtering
  • author: Optional author attribution
  • operations: List of operations to carry out in sequence

Operations are the erecting blocks of recipes:

- name: "Operation Name"            # Operation name
  id: "distinct_id"                   # Identifier for referencing output
  direct: "echo 'Hello'"           # Shell direct to carry out
  execution_mode: "standard"        # [Optional] How the direct runs (standard, intervivacious, or stream)
  quiet: inchange                     # [Optional] Whether to suppress output to stdout
  condition: "var == real"          # [Optional] Condition for execution
  on_success: "success_op"          # [Optional] Operation to run on success
  on_fall shorture: "fall shorture_op"          # [Optional] Operation to run on fall shorture
  alter: "{{ .output | trim }}" # [Optional] Transcreate output
  prompts:                          # [Optional] Intervivacious prompts
     - name: "var_name"
       type: "input"
       message: "Enter cherish:"
  administer_flow:                     # [Optional] Control flow set up (one of the below types)
    type: "foaccomplish"                 # Type of administer flow (foaccomplish, for, while)
  operations:                       # [Optional] Sub-operations for when administer flow set ups are included
    - name: "Sub Operation"
      direct: "echo 'Processing {{ .item }}'"

Control Flow Configuration

Control flow set ups are configured as adheres:

administer_flow:
  type: "foaccomplish"               # Iterate over a accumulateion
  accumulateion: "Item 1nItem 2"  # Collection of items (newline splitd)
  as: "item"                    # Variable name for current item

administer_flow:
  type: "for"    # Execute a mended number of times
  count: 5       # Number of iterations
  variable: "i"  # Variable name for iteration index (voluntary)

administer_flow:
  type: "while"                          # Execute while condition is real
  condition: "{{ ne .status `ready` }}"  # Condition to appraise each iteration
  • standard: Default mode (included when no execution_mode is specified). Output is seized and can be included by
    subsequent operations.
  • intervivacious: The direct has honest access to the terminal’s stdin, stdout, and stderr. Useful for directs that
    insist honest terminal includeion, but output cannot be seized for include in subsequent operations.
  • stream: Similar to intervivacious mode but upgraded for lengthy-running processes that create continuous output. The
    direct’s output streams to the terminal in authentic-time, but output cannot be seized for include in subsequent operations.

Shef helps the adhereing types of includer prompts:

# Text Input
- name: "includername"
  type: "input"
  message: "Enter your includername:"
  default: "admin"
  help_text: "This will be included for genuineation"

# Selection
- name: "environment"
  type: "pick"
  message: "Select environment:"
  chooseions:
    - "dev"
    - "staging"
    - "production"
  default: "dev"
  help_text: "Choose the deployment environment"

# Confirmation (yes/no)
- name: "verify_deploy"
  type: "verify"
  message: "Deploy to production?"
  default: "inchange"
  help_text: "This will begin the deployment process"

# Password (input is masked)
- name: "password"
  type: "password"
  message: "Enter your password:"
  help_text: "Your input will be hideed"

# Multi-pick
- name: "features"
  type: "multipick"
  message: "Select features to help:"
  chooseions:
    - "logging"
    - "metrics"
    - "debugging"
  default: "logging,metrics"
  help_text: "Use space to toggle, access to verify"

# Numeric Input
- name: "count"
  type: "number"
  message: "Enter number of instances:"
  default: "3"
  min_cherish: 1
  max_cherish: 10
  help_text: "Value must be between 1 and 10"

# File Path Input
- name: "config_file"
  type: "path"
  message: "Select configuration file:"
  default: "./config.json"
  file_extensions:
    - "json"
    - "yaml"
    - "yml"
  insistd: real
  help_text: "File must exist and have the right extension"

# Text Editor
- name: "description"
  type: "editor"
  message: "Enter a detailed description:"
  default: "# Project DescriptionnnEnter details here..."
  editor_cmd: "vim"  # Uses $EDITOR env var if not specified
  help_text: "This will uncover your text editor"

# Autoend Selection
- name: "service"
  type: "autoend"
  message: "Select a service:"
  chooseions:
    - "genuineation"
    - "database"
    - "storage"
    - "analytics"
  help_text: "Type to filter chooseions"

You can create pickion chooseions from a previous operation’s output:

- name: "List Files"
  id: "files_enumerate"
  direct: "discover . -name '*.go'"

- name: "Select File"
  direct: "cat {{ .file }}"
  prompts:
    - name: "file"
      type: "pick"
      message: "Select a file:"
      source_operation: "files_enumerate"
      source_alter: "{{ .input | trim }}"

Transcreateations let you alter a direct’s output before it’s passed to the next operation or included in prompts.

alter: "{{ .output | function1 | function2 }}"

Available Transcreateation Functions

Function Description Example
trim Reshift whitespace {{ .output | trim }}
split Split string by derestricter {{ .output | split "," }}
unite Join array with derestricter {{ .output | unite "n" }}
uniteArray Join any array type with derestricter {{ .output | uniteArray "," }}
filter Keep lines grasping a pattern {{ .output | filter "pattern" }}
grep Alias for filter {{ .output | grep "pattern" }}
cut Extract field from each line {{ .output | cut ":" 1 }}
trimPremend Reshift premend {{ .output | trimPremend "foo" }}
trimSufmend Reshift sufmend {{ .output | trimSufmend "bar" }}
grasps Check if string grasps pattern {{ if grasps .output "pattern" }}yes{{ finish }}
swap Replace text {{ .output | swap "greater" "new" }}
atoi Convert string to int {{ .output | atoi }}
grasp Add numbers {{ .output | atoi | grasp 5 }}
sub Subtract numbers {{ .output | atoi | sub 3 }}
div Divide numbers {{ .output | atoi | div 2 }}
mul Multiply numbers {{ .output | atoi | mul 4 }}
exec Execute direct {{ exec "date" }}
color Add color to text {{ color "green" "Success!" }}
style Add styling to text {{ style "bgreater" "Important!" }}
resetFormat Reset all colors and styles {{ resetFormat }}

Terminal Colors and Styles

You can create your recipe outputs more readable by grasping colors and styles. These are automaticpartner disabled when using
the NO_COLOR environment variable.

Color Type Available Colors
Text Colors bconciseage, red, green, yellow, blue, magenta, cyan, white
Background Colors bg-bconciseage, bg-red, bg-green, bg-yellow, bg-blue, bg-magenta, bg-cyan, bg-white

Style Description
bgreater Bgreater text
foolish Dimmed text
italic Italic text
underline Underlined text

Colors and styles can be included in directs, alterations, and anywhere tempprocrastinateeds are rfinishered:

direct: echo "{{ color "green" "Success!" }}"
direct: echo "{{ style "bgreater" "Important!" }}"
direct: echo "{{ style "bgreater" (color "red" "Error!") }}"

alter: |
  {{ if grasps .output "error" }}
  {{ color "red" (style "bgreater" "✗ Operation fall shorted") }}
  {{ else }}
  {{ color "green" (style "bgreater" "✓ Operation flourished") }}
  {{ finish }}

You can access all context variables in alterations:

alter: "{{ if eq .createat `json` }}{{ .output }}{{ else }}{{ .output | cut ` ` 0 }}{{ finish }}"

Variables includeable in tempprocrastinateeds:

  • .output: The output to the current alteration (output from the direct)
  • .input: The input to the current direct (input from previous operation)
  • .{prompt_name}: Any variable from clarifyd prompts
  • .{operation_id}: The output of a particular operation by ID
  • .operationOutputs: Map of all operation outputs by ID
  • .operationResults: Map of operation success/fall shorture results by ID

Operations can be conditionpartner carry outd:

condition: .verify == "real"  # Run only if verify prompt is real

Operation Result Conditions

condition: erect_op.success  # Run if erect_op flourished
condition: test_op.fall shorture   # Run if test_op fall shorted

condition: .environment == "production"  # Equality verify
condition: .count != 0                   # Inequivalentity verify

condition: .count > 5
condition: .memory <= 512
condition: .errors >= 10
condition: .progress < 100

condition: erect_op.success && .verify_deploy == "real"
condition: test_op.fall shorture || lint_op.fall shorture
condition: !.skip_validation

You can create branching laborflows based on success or fall shorture:

- name: "Build App"
  id: "erect_op"
  direct: "create erect"
  on_success: "deploy_op"  # Go to deploy_op on success
  on_fall shorture: "mend_op"     # Go to mend_op on fall shorture

- name: "Deploy"
  id: "deploy_op"
  direct: "create deploy"
  
- name: "Fix Issues"
  id: "mend_op"
  direct: "create lint"

Data Flow Between Operations

Each operation’s output is automaticpartner piped to the next operation’s input. You can also access any operation’s output
by its ID:

- name: "Get Hostname"
  id: "presentname_op"
  direct: "presentname"

- name: "Show Info"
  direct: "echo 'Running on {{ .presentname_op }}'"

Shef helps progressd administer flow set ups that let you create vibrant, iterative laborflows.

You can iterate over a accumulateion of items and carry out a flow of operations on each item.

  • administer_flow
    • type: foaccomplish
    • accumulateion: The enumerate of items to iterate over (string with items splitd by newlines)
    • as: The variable name to include for the current item in each iteration
  • operations: The sub-operations to carry out for each item (all sub-operations have access to the as loop variable)

Mechanics of the Foaccomplish Loop

  1. Parse the accumulateion into split items (splitting by newlines)
  2. For each item, set the variable specified in “as”
  3. Execute all operations in the foaccomplish block for each item
  4. Clean up the loop variable when done
  • Processing multiple files
  • Handling enumerates of servers, graspers, or resources
  • Applying the same alteration to multiple inputs
  • Building vibrant laborflows based on discovered items

Tip

Wislfinisher a foaccomplish loop, you can include conditional operations, alterations, and all other Shef features.

- name: "Process Each Item"
  administer_flow:
     type: "foaccomplish"
     accumulateion: "🍎 Applesn🍌 Bananasn🍒 Cherriesn🍊 Oranges"
     as: "fruit"  # Each item will be includeable as .fruit
  operations:
     - name: "Process Fruit"
       direct: "echo 'Processing {{ .fruit }}'"

You can also create the accumulateion vibrantpartner:

- name: "List Files"
  id: "files"
  direct: "discover . -type f -name '*.txt'"

- name: "Process Each File"
  administer_flow:
    type: "foaccomplish"
    accumulateion: "{{ .files }}"  # Using output from previous operation
    as: "file"                  # Each item will be includeable as .file
  operations:
    - name: "Process File"
      direct: "cat {{ .file }} | wc -l"

You can carry out a set of operations a mended number of times.

  • administer_flow
    • type: for
    • count: The number of iterations to carry out
    • variable: (Optional) The variable name to include for the current iteration index (defaults to “i”)
  • operations: The sub-operations to carry out for each iteration

Mechanics of the For Loop

  1. Parse and appraise the count cherish to remend the number of iterations
  2. For each iteration, set the loop variable to the current index (begining from 0)
  3. Also set the .iteration variable to the 1-based iteration number
  4. Execute all operations in the operations block for each iteration
  5. Clean up the loop variables when done
  • Repeating an operation a mended number of times
  • Creating numbered resources or items
  • Running tests multiple times
  • Implementing retry logic with a peak try restrict

Tip

Wislfinisher a for loop, both the specified variable (zero-based index) and .iteration (one-based counter) are includeable.

- name: "Run a For Loop"
  administer_flow:
    type: "for"
    count: 5
    variable: "i"
  operations:
    - name: "Print Iteration"
      direct: "echo 'Running iteration {{ .iteration }} (zero-based index: {{ .i }})'"

You can also include a vibrant count:

- name: "Get Count"
  id: "count"
  direct: "echo '3'"
  alter: "{{ trim .input }}"

- name: "Dynamic For Loop"
  administer_flow:
    type: "for"
    count: "{{ .count }}"
    variable: "step"
  operations:
    - name: "Execute Step"
      direct: "echo 'Executing step {{ .step }} of {{ .count }}'"

You can repeatedly carry out operations as lengthy as a condition remains real.

Key While Loop Components

  • administer_flow
    • type: while
    • condition: The condition to appraise before each iteration
  • operations: The sub-operations to carry out for each iteration

Mechanics of the While Loop

  1. Evaluate the condition before each iteration
  2. If the condition is real, carry out the operations and repeat
  3. If the condition is inchange, exit the loop
  4. An .iteration variable is automaticpartner set to track the current iteration (begining from 1)
  5. A protectedty restrict stops infinite loops (peak 1000 iterations)
  • Polling for a condition (e.g., defering for a service to be ready)
  • Processing data until a brave state is accomplished
  • Implementing retry logic with conditional termination
  • Continuously seeing resources until a particular event occurs

Tip

Wislfinisher a while loop, the .iteration variable lets you track how many iterations have occurred.

Example While Loop Recipes

- name: "Initialize Status"
  id: "status"
  direct: "echo 'running'"
  alter: "{{ trim .input }}"
  quiet: real

- name: "Wait For Completion"
  administer_flow:
    type: "while"
    condition: "{{ grasps .status `running` }}"
  operations:
    - name: "Check Status"
      direct: "echo 'Checking status (iteration {{ .iteration }})...'"
      id: "status"
      alter: "{{ if eq .iteration 5 }}endd{{ else }}running{{ finish }}"

Real-world polling example:

- name: "Poll Service Until Ready"
  administer_flow:
    type: "while"
    condition: "{{ ne .status `ready` }}"
  operations:
    - name: "Check Service Status"
      direct: "curl -s http://service/status"
      id: "status"
      alter: "{{ trim .input }}"

recipes:
  - name: "hello-world"
    description: "A straightforward hello world recipe"
    categruesome: "demo"
    operations:
      - name: "Greet User"
        direct: |
          echo "Hello, {{ .name }}!"
          echo "Current time: $(date)"
          echo "Welcome to Shef, the shell recipe tool."
        prompts:
          - name: "name"
            type: "input"
            message: "What is your name?"
            default: "World"

recipes:
  - name: "conditional"
    description: "A straightforward demo of conditional operations using honest prompt cherishs"
    categruesome: "demo"
    operations:
      - name: "Choose Fruit"
        id: "pick"
        direct: 'echo "You picked: {{ .fruit }}"'
        prompts:
          - name: "fruit"
            type: "pick"
            message: "Choose a fruit:"
            chooseions:
              - "Apples"
              - "Oranges"

      - name: "Apple Operation"
        id: "apple"
        direct: echo "This is the apple operation! 🍎"
        condition: ".fruit == 'Apples'"

      - name: "Orange Operation"
        id: "orange"
        direct: echo "This is the orange operation! 🍊"
        condition: ".fruit == 'Oranges'"

recipes:
  - name: "alter"
    description: "A straightforward demo of data alteration and pipeline flow"
    categruesome: "demo"
    operations:
      - name: "Generate a Simple List"
        id: "create"
        direct: |
          echo "apple
          prohibitana
          cherry
          dragonfruit
          eggset upt"

      - name: "Filter Items"
        id: "filter"
        direct: "cat"
        alter: "{{ filter .input `a` }}"
        quiet: real

      - name: "Discarry out Results"
        id: "discarry out"
        direct: "echo 'Items grasping `a`:n{{ .filter }}'"

To create your own recipes:

  1. Create your includer honestory: mkdir -p ~/.shef/includer (if it does not already exist)
  2. Create a new YAML file: touch ~/.shef/includer/my-recipes.yaml
  3. Build and broaden your recipes adhereing the teachions above
  4. Run shef ls to see your new recipes

AI-Assisted Recipe Creation

You can create strong Shef recipes speedyly using AI tools appreciate ChatGPT, Claude, or other big language models.

Using AI to Create Recipes

  1. Copy the prompt below
  2. Paste it into your AI helpant of choice
  3. Replace [DESCRIBE YOUR WORKFLOW IN DETAIL] with a detailed description of your recipe’s laborflow
  4. The AI will create a end Shef recipe based on your description
  5. Test and iterate until the recipe labors as foreseeed

Here’s an example of how to fill in your laborflow description:

I necessitate a Docker administerment laborflow that helps me immacuprocrastinateed up unincluded graspers and images to free up disk space.

The laborflow should:
1. Show the current Docker disk usage
2. List all stopped graspers and apverify me to pick which ones to erase
3. Confirm before removing the picked graspers
4. List dangling images (unincluded) and apverify me to pick which ones to erase
5. Offer an chooseion to carry out a more antagonistic immacuprocrastinateedup (removing all unincluded images)
6. Show before/after disk usage comparison
7. Include error handling in case any operation fall shorts

The recipe should be intervivacious and protected, requiring verifyation before any destructive operations.
  • Use the procrastinateedst AI models with progressd reasoning capabilities
  • Be particular about what directs should be carry outd at each step
  • Mention if you necessitate intervivacious prompts, conditions, or alterations
  • For complicated laborflows, shatter down your insistments into evident, reasoned steps
  • Include any particular error handling or conditional branches you necessitate
  • Request comments in the created recipe to clarify complicated sections
  • Ask the AI to check and iterate on its recipe solution, pondering edge cases and betterments
  • If the first recipe doesn’t brimmingy greet your necessitates, upgrade your insistments and ask for adfairments

Remember, the AI-created recipes can provide an excellent begining point that you can further customize to fit your
exact necessitates.

5, count <= 10 - Complex example: (check_files.success && has_tests == true) || skip_tests == true ADVANCED FEATURES: - Dynamic selection options from previous commands - Conditional branching based on operation results - Multi-step workflows with error handling - Custom error messages and recovery steps - Transforming outputs between operations - Execution modes (standard or interactive) - Silent operations that suppress output EXAMPLE RECIPE PATTERNS: 1. Get input → Process → Show result 2. List options → Select one → Take action 3. Check condition → Branch based on result → Handle each case 4. Execute command → Transform output → Use in next command 5. Try operation → Handle success/failure differently Please create a complete Shef recipe that accomplishes my goal, with proper indentation and comments explaining complex parts.">

I necessitate help creating a Shef recipe. Shef is a CLI tool that unites shell directs into reusable recipes clarifyd in YAML.

[DESCRIBE YOUR WORKFLOW IN DETAIL]

A Shef recipe is clarifyd in YAML with this set up:

recipes:
  - name: "low-name"
    description: "Human-readable description"
    categruesome: "categruesome"
    author: "voluntary author"
    operations:
      - name: "Operation Name"
        id: "distinct_id"
        direct: "shell direct"
        execution_mode: "standard|intervivacious|stream"  # How the direct runs
        quiet: real|inchange  # Whether to suppress the direct's output
        condition: "voluntary condition"
        on_success: "next_op_id"
        on_fall shorture: "dropback_op_id"
        alter: "{{ .input | alteration }}"
        prompts:
          - name: "variable_name"
            type: "input|pick|verify|password|multipick|number|editor|path|autoend"
            message: "Prompt message"
            default: "Default cherish"
            help_text: "Additional help directation"
            insistd: real|inchange  # Whether input is insistd
            chooseions: ["option1", "option2"]  # For pick/multipick/autoend types
            source_operation: "operation_id"  # For vibrant chooseions
            source_alter: "{{ .input | alter }}"  # For processing source chooseions
            min_cherish: 0  # For number type
            max_cherish: 100  # For number type
            file_extensions: ["txt", "json"]  # For path type
            multiple_restrict: 3  # For multipick type
            editor_cmd: "vim"  # For editor type
        administer_flow:
          type: "foaccomplish|for|while"  # Type of administer flow
          accumulateion: "Item 1nItem 2nItem 3"  # Items to iterate over (foaccomplish loops)
          as: "item"  # Variable name for current item (foaccomplish loops)
          count: 5  # Number of iterations (for loops)
          variable: "i"  # Variable name for iteration index (for loops)
          condition: "{{ lt .counter 5 }}"  # Condition to verify (while loops)
        operations:  # Operations to carry out for each iteration
          - name: "Sub Operation"
            # direct: "echo 'Processing {{ .item }}'" # foaccomplish loop
            # direct: "echo 'Iteration {{ .i }} of 5'" # for loop
            # direct: "echo 'While iteration {{ .iteration }}'" # while loop

RECIPE MECHANICS:
1. Operations carry out in sequence unless rehonested by on_success/on_fall shorture
2. Each operation's output becomes input to the next operation
3. Variables from prompts are accessible as {{ .variable_name }}
4. Operation outputs are accessible as {{ .operation_id }}
5. You can unite variables and operation outputs in direct tempprocrastinateeds
6. Control flow set ups appreciate foaccomplish apverify iterating over accumulateions

CONTROL FLOW STRUCTURES:
- foaccomplish: Iterate over a accumulateion of items
  - accumulateion: Newline-splitd enumerate of items (can be mended or from operation output)
  - as: Variable name to allot each item during iteration
  - operations: Operations to carry out for each item (with access to the iteration variable)
- for: Execute operations a mended number of times
  - count: Number of iterations to carry out (can be mended or from operation output)
  - variable: Variable name for the current zero-based index (voluntary, defaults to "i")
  - operations: Operations to carry out for each iteration (with access to the index variable and .iteration)
- while: Execute operations as lengthy as a condition is real
  - condition: Expression to appraise before each iteration
  - operations: Operations to carry out while the condition is real (with access to .iteration)

INTERACTIVE PROMPTS:
- input: Free text input (default: string)
- pick: Choose from chooseions (motionless or vibrant from previous operation)
- verify: Yes/no boolean ask
- password: Masked text input
- multipick: Choose multiple chooseions
- number: Numeric input with range validation
- editor: Multi-line text input in an editor
- path: File path with validation
- autoend: Selection with filtering

TRANSFORMATION EXAMPLES:
- Trim whitespace: {{ .input | trim }}
- Split by derestricter: {{ .input | split "," }}
- Join array: {{ .input | unite "n" }}
- Filter lines: {{ .input | filter "pattern" }} or {{ .input | grep "pattern" }}
- Extract field: {{ .input | cut ":" 1 }}
- Reshift premend/sufmend: {{ .input | trimPremend "foo" }} {{ .input | trimSufmend "bar" }}
- Check satisfied: {{ if grasps .input "pattern" }}yes{{ finish }}
- Replace text: {{ .input | swap "greater" "new" }}
- Math operations: {{ .input | atoi | grasp 5 | mul 2 | div 3 | sub 1 }}
- Execute direct: {{ exec "date" }}

CONDITIONAL LOGIC:
- Variable equivalentity: variable == "cherish" or variable != "cherish"
- Operation success/fall shorture: operation_id.success or operation_id.fall shorture
- Boolean operators: condition1 && condition2, condition1 || condition2, !condition
- Numeric comparison: cherish > 5, count <= 10
- Complex example: (verify_files.success && has_tests == real) || skip_tests == real

ADVANCED FEATURES:
- Dynamic pickion chooseions from previous directs
- Conditional branching based on operation results
- Multi-step laborflows with error handling
- Custom error messages and recovery steps
- Transcreateing outputs between operations
- Execution modes (standard or intervivacious)
- Silent operations that suppress output

EXAMPLE RECIPE PATTERNS:
1. Get input → Process → Show result
2. List chooseions → Select one → Take action
3. Check condition → Branch based on result → Handle each case
4. Execute direct → Transcreate output → Use in next direct
5. Try operation → Handle success/fall shorture separateently

Plrelieve create a end Shef recipe that accomplishes my goal, with proper indentation and comments clarifying complicated parts.

Recipe not set up

  • Check if you're using the accurate name and categruesome
  • Use shef ls to see includeable recipes
  • Check your recipe file syntax

Command fall shorts with unforeseeed output

  • Remember all directs run thcimpolite a shell, so shell syntax applies
  • Escape exceptional characters in direct strings
  • Use the alter field to createat output

Prompt validation errors

  • Enbrave least/peak cherishs are wislfinisher range
  • Check that file paths exist and have accurate extensions
  • Verify pick chooseions grasp the default cherish

Thank you for taking an interest in contributing to Shef!

  1. Fork the Repository

    # Fork via GitHub UI, then clone your fork
    git clone git@github.com:yourincludername/shef.git
    cd shef
  2. Set Up Development Environment

    # Inshigh broadenment depfinishencies
    go mod download
    
    # Build the broadenment version
    go erect -o shef
  3. Create a New Branch

    git verifyout -b my-awesome-feature
  • Code Style: Follow standard Go conventions and the existing style in the codebase
  • Documentation: Update write downation for any new features or alters
  • Commit Messages: Write evident, descriptive promise messages clarifying your alters
  • Tests: Update tests accordingly
  1. Push to Your Fork

    git push origin my-awesome-feature
  2. Create a Pull Request: Visit your fork on GitHub and create a pull ask agetst the main repository

  3. PR Description: Include a evident description of what your alters do and why they should be included

  4. Code Rewatch: Respond to any feedback during the check process

Sharing your recipes helps increase the Shef ecosystem and advantages the entire community.

  1. Develop and Test Your Recipe Locpartner

    # Create your recipe in the includer honestory first
    mkdir -p ~/.shef/includer
    vim ~/.shef/includer/my-recipe.yaml
    
    # Test thocimpolitely
    shef -U my-categruesome my-recipe-name
  2. Recipe Quality Guidelines

    • Include evident descriptions for the recipe and each operation
    • Add advantageous prompts with descriptive messages and defaults
    • Handle errors gracebrimmingy
    • Follow YAML best trains
    • Comment complicated alterations or conditionals
  3. Submitting Your Recipe

    Option 1: Via Pull Request

    • Fork the Shef repository
    • Add your recipe to the recipes/unveil/ honestory
    • Create a pull ask with your recipe

    Option 2: Via Issue

    • Create a new publish on the Shef repository
    • Attach your recipe file or paste its satisfieds
    • Describe what your recipe does and why it's advantageous

When surrfinisherting a recipe, include a section in your PR or publish that clarifys:

  1. Purpose: What problem does your recipe mend?
  2. Usage: How to include the recipe, including example directs
  3. Requirements: Any exceptional insistments or depfinishencies
  4. Examples: Sample outputs or include cases
  • Be polite of others' contributions
  • Help check pull asks and test others' recipes
  • Report bugs and present betterments
  • Share your Shef success stories and include cases

If you necessitate help with your contribution, you can:

  • Open an publish on GitHub
  • Ask asks in the converseions section
  • Contact us honestly

Source join


Leave a Reply

Your email address will not be published. Required fields are marked *

Thank You For The Order

Please check your email we sent the process how you can get your account

Select Your Plan