Skip to main content

A Windows command-line automation framework that lets you create global commands using Python.

Project description


DIAMONDCLI — Build Command Lines Like a BOSS

DiamondCLI is a Python library that lets you create global Windows commands using simple Python scripts.
It behaves like a tiny custom operating system inside your user folder.


What DiamondCLI Does

When installed, DiamondCLI automatically creates:

C:\Users\<your username>\dcli

This folder becomes your command center.
Any .py script you drop inside it becomes a runnable command.

Example:

dcli run notif

Boom — your Python command runs globally from ANY directory.


Setting Up the Global dcli Command

To make dcli a real Windows command, you need two files inside your dcli folder:

1. dcli.bat

This ensures Windows can run the launcher even if .py files aren’t associated with Python.

Create:

C:\Users\<your username>\dcli\dcli.bat

Put this inside:

@echo off
python "%~dp0dcli.py" %*

2. dcli.py

This is the actual launcher that loads your command scripts.

Create:

C:\Users\<your username>\dcli\dcli.py

Put this inside:

import sys
import os
import importlib.util
import diamondcli
import getpass

USERNAME = getpass.getuser()
SCRIPTS_DIR = fr"C:\Users\{USERNAME}\dcli"

def load_scripts():
    if not os.path.isdir(SCRIPTS_DIR):
        print(f"[dcli] Script directory not found: {SCRIPTS_DIR}")
        return

    for filename in os.listdir(SCRIPTS_DIR):
        if filename.endswith(".py"):
            path = os.path.join(SCRIPTS_DIR, filename)
            mod_name = filename[:-3]

            spec = importlib.util.spec_from_file_location(mod_name, path)
            module = importlib.util.module_from_spec(spec)
            spec.loader.exec_module(module)

def main():
    load_scripts()
    diamondcli.core.cli_main(sys.argv[1:])

if __name__ == "__main__":
    main()

This launcher:

  • detects the user’s real Windows username
  • loads every .py script in the dcli folder
  • registers commands
  • runs them globally

Add the Folder to PATH

Open Environment VariablesPathEditNew
Add:

C:\Users\<your username>\dcli

Press OK on everything.

Restart CMD or PowerShell.


Test It

Run:

dcli

If you see:

[diamondcli] No arguments. Usage: dcli run <command>

You did everything right.

Now create a script:

C:\Users\<your username>\dcli\test.py

Put this inside:

import diamondcli as dcli
from diamondcli import *

@dcli.command("test")
def test():
    log("Test command started")
    shownotif("DiamondCLI Test", "Your test command is working!", duration=5)
    log("Test command finished")
    end()

Run it:

dcli run test

You now have a real global command powered by Python.


Summary

  • DiamondCLI auto‑creates your command folder
  • You add a launcher + batch wrapper
  • You add the folder to PATH
  • You drop Python scripts inside
  • You run them globally with dcli run <command>

You just built your own mini command‑line operating system.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diamondcli-1.0.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diamondcli-1.0.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file diamondcli-1.0.1.tar.gz.

File metadata

  • Download URL: diamondcli-1.0.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for diamondcli-1.0.1.tar.gz
Algorithm Hash digest
SHA256 63f1ba5c701d1b8c8aafdd69c96ca1c26ab23e3ec86cd32de5bf72180e4f18da
MD5 0aad605207d7bd9e15ce05287503dce9
BLAKE2b-256 7c34d795e1dbc3cdf184dea829c5a6009ee3a85b1149d51a7106a000500632da

See more details on using hashes here.

File details

Details for the file diamondcli-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: diamondcli-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for diamondcli-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0f042933d80044923810c01e7968526d8aa27b53fdf99cee22786dc72ed4f4ae
MD5 e8f0d0c2ebdc5a53b1088dd4658b95b2
BLAKE2b-256 80e94b5e03670f7ed7ddc6547c25f0e595d8e7d8a1228f0242413676a9cd2927

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page