Skip to main content

CMDS Helper

This modul will help us to automate CLI Command we usually use in projects.

Installation

Using pip :

pip install cmds-helper

How To Use

  • Install cmds-helper module using pip

  • Make runner file in root of your project files directory (i.e run.py)

    --ProjectDir
        --{{Your project files/folder}}
        --run.py
        --{{your cmd json file}}cmd.json
    
  • Import cmdshelper Helper class

    from cmdshelper.helper import Helper
    
  • Instantiate the Helper class

    cmd = Helper()
    
  • Make command json file. You can make many cmd json file for grouping cmd or just make 1 cmd json file. The program will read all json file ends with cmd.json in your project directory and add it to list_command in Helper class. The syntax is :

    {
        "{your_cmd_identifier}" : [
            "{cmd_command_to_run}",
            "{cmd_command_to_run}",
            ...
        ],
        "{your_cmd_identifier}" : [
            "{cmd_command_to_run}",
            "{cmd_command_to_run}",
            ...
        ],
        ...
    }
    
    • {your_cmd_identifier} is identifier for calling all cmd command under that identifier. every identifier must be unique

    • cmd_command_to_run is the cmd command you want to run. The command is string you usually type in CLI, but in the json file, you separate every command/optional/arguments using space / ' ' like usual.

    • In cmd_command_to_run, you can add argument to pass, with type %{i} (i is index arguments passes)

  • Example :

    "gitACP" : [
            "git add .",
            "git commit -m %1",
            "git push"
        ]
    

    the identifier to call that command is gitACP (command to call git common command [add, commit, and push]). under that identifier, we specify all command we want to call

    • "git add ."
    • "git commit -m "{message}" " is typed "git commit -m %1"
      • %1 means that the first argument passed when calling that command identifier, will replacing %1 into the passed string
      • If you just want add same commit message for each commit, you can just change %1 into your message like feat: add something
    • "git push"

    You can see another command examples in example_cmd.json

  • There are 4 ways to run this file, by CLI with passing arg, by hardcode the command in script, or by using python -m

    • CLI Passing argument :

      • After instantiate the class, you can type this code :

        import sys
        
        cmd.run(sys.argv[1:])
        
      • To run it, you just need to run the file and passing the command identifier and argument if needed

      • Example run it in CommandPrompt

        py run.py gitACP "feat: add something
        

        that will call the gitACP command and pass feat: add something as commit message

    • Hardcoded Command :

      • After instantiate the class, you can type this code :

        cmd.run([{your command here}])
        
      • Example :

        cmd.run(["gitACP","feat: add something"])
        

        to run it, you just need to run run.py file

    • Straight from Python module

      It is just as simple as you open the folder that you want to run the command

      python -m cmdshelper [command] [args_1] [args_2] ... [args_3]
      

      for example:

      python -m cmdshelper gitACP "feat: add something"
      
    • Simply just cdmshelper

      It is just as simple as you open the folder that you want to run the command

      cmdshelper [command] [args_1] [args_2] ... [args_3]
      

      for example:

      cmdshelper gitACP "feat: add something"
      
  • Full code in run.py will be :

    from cmdshelper.helper import Helper
    import sys
    
    cmd = Helper()
    
    # run using cli
    cmd.run(sys.argv[1:])
    
    # run using hardcode command
    #cmd.run(["gitACP","feat: add something"])
    

License

This project is licensed under the terms of the MIT license.

Metadata

Release files for cmds-helper 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cmds-helper 0.1.1
File Size Uploaded
cmds_helper-0.1.1.tar.gz 6.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cmds-helper 0.1.1
File Interpreter ABI Platform
cmds_helper-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / cmds_helper-0.1.1.tar.gz

Download URL cmds_helper-0.1.1.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7704e4f72995f69f8b17ec13607feeee65e7617eb05ea9537d01b101ab6acf8b
BLAKE2b-256 checksum
How to use checksums
d3e85f568f2365e12ff8aa0068dd3c4c6396411cd43067593ee375b327456da4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release files / cmds_helper-0.1.1-py3-none-any.whl

Download URL cmds_helper-0.1.1-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebf579fc5d8769ef3194a10cea51645d646a4232e4d892ac7fb91d68aa56d2c5
BLAKE2b-256 checksum
How to use checksums
0e7ac0cd6cb7336d2f6ecf2bd8630993474c11ac2f73b5744f6520cb84f0a54f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page