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-0.1.0.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-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: diamondcli-0.1.0.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-0.1.0.tar.gz
Algorithm Hash digest
SHA256 63a984092137c4708f26b36f496eca1ec93f5ddc8e9907a0563964067d5bd6e5
MD5 ab739f475532f0b7baa774220757d86a
BLAKE2b-256 63ecd7157a950cf5041ae33e2ab2698062c874f5a9ed95aa3b9505393f4eb069

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for diamondcli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22acae39ef6c837f6f50185350aa06a243cbade97da233840969a16b82c9ecca
MD5 bd44b3f1e19716b402e6c88e39304ab3
BLAKE2b-256 137c79f9781bca83173ba3f356c8605f9a464de3c85372bb5315dd7bca9bc673

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