Giter Site home page Giter Site logo

cmd_switch's Introduction

cmd_switch

Overview

cmd_switch is a versatile tool designed to manage and execute tasks dynamically based on a pre-defined JSON configuration. It allows users to easily switch between different commands, making it ideal for scenarios requiring multiple or conditional command executions.

Features

  • Load JSON Configurations: Effortlessly load configurations defined in a JSON file, specifying labels and commands to execute.
  • Grouping Commands: Organize related tasks into groups for better management and clarity.
  • Simple Command Line Interface: Use a straightforward CLI to manage and execute tasks quickly.

Configuration

cmd_switch uses a JSON file to define tasks. Each task must specify a label and a cmd. Tasks can be grouped under a group label for better organization.

Example JSON Configuration

[
    {
        "label": "Display Current Directory",
        "cmd": "pwd"
    },
    {
        "label": "List All Files",
        "cmd": "ls -a"
    },
    {
        "group": "File Operations",
        "config": [
            {
                "label": "Create New File",
                "cmd": "touch newfile.txt"
            },
            {
                "label": "Write to File",
                "cmd": "echo 'Hello, World!' > newfile.txt"
            },
            {
                "label": "Read File",
                "cmd": "cat newfile.txt"
            }
        ]
    },
    {
        "group": "System Info",
        "config": [
            {
                "label": "Check Disk Usage",
                "cmd": "df -h"
            },
            {
                "label": "Memory Usage",
                "cmd": "free -h"
            }
        ]
    },
    {
        "label": "Echo Custom Message",
        "cmd": "echo 'This is a custom message.'"
    }
]

This configuration defines commands for displaying directory information, listing files, grouped file operations, system information checks, and custom messaging.

Installation

To use cmd_switch, clone the repository or download the latest release and build it with cargo build --release.

Usage

To execute commands with cmd_switch, you need to specify the path to your JSON configuration file using the --config-path argument.

  cmd_switch --config-path example.json

cmd_switch's People

Contributors

lupuszr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.