Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

micro-swiss (ms)

A developer utility CLI written in Rust. 28 subcommands covering text processing, encoding, hashing, date math, file ops, networking, database connectivity, and more β€” with automatic module discovery and clipboard integration.

Motivation

AI coding agents and developers repeatedly perform the same small operations β€” encoding, hashing, formatting, converting. ms puts them all behind one binary with zero startup cost.

Installation

# Build optimized release binary
cargo build --release --all-features

# Binary is at target/release/ms
# Optionally install globally:
cargo install --path .

Feature Flags

Flag Includes Default
db PostgreSQL (ms db) yes (via full)
http HTTP client (ms http) yes (via full)
full Both db + http yes
cargo build --release                    # everything
cargo build --release --no-default-features  # minimal, no db/http
cargo build --release --features db      # only db

Commands

Encoding & Decoding

ms base64 encode "hello"              # aGVsbG8=
ms base64 decode "aGVsbG8="           # hello
echo "hello" | ms base64 encode       # stdin works everywhere

ms url encode "hello world"           # hello+world
ms url decode "hello+world"           # hello world
ms url parse "https://example.com?a=1"  # structured JSON output

Hashing & Checksums

ms hash "hello"                       # SHA256 (default), copied to clipboard
ms hash "hello" md5                   # MD5
echo "secret" | ms hash              # stdin

ms checksum file.txt                  # SHA256 file checksum
ms checksum file.txt md5              # MD5 file checksum

Password & UUID

ms password                           # 16-char secure password, copied
ms password 32                        # custom length

ms uuid                               # UUID v4 (random), copied
ms uuid v7                            # UUID v7 (timestamp)

Text Processing

ms case upper "hello world"           # HELLO WORLD
ms case camel "hello world"           # helloWorld
ms case snake "helloWorld"            # hello_world
ms case kebab "helloWorld"            # hello-world
ms case pascal "hello world"          # HelloWorld
ms case constant "hello world"        # HELLO_WORLD
ms case title "hello world"           # Hello World

ms flatten "line1\nline2"             # line1line2
echo -e "line1\nline2" | ms flatten   # stdin

ms inspect "hello 🌍"                # byte count, chars, lines, words, codepoints

JSON

ms json pretty '{"a":1,"b":2}'       # pretty print, copied
ms json minify '{ "a": 1 }'          # minify, copied
echo '{"a":1}' | ms json pretty      # stdin

Format Conversion

ms convert yaml '{"name":"test"}'     # JSON β†’ YAML
ms convert json "name: test"          # YAML β†’ JSON
ms convert toml '{"name":"test"}'     # JSON β†’ TOML

Date & Time

ms date add 01/01/2024 10            # 11/01/2024 (Thursday)
ms date sub 11/01/2024 10            # 01/01/2024 (Monday)
# Formats: DDMMYYYY, DD/MM/YYYY, DD-MM-YYYY

ms epoch                              # current epoch + UTC
ms epoch 1700000000                   # epoch β†’ human date
ms epoch "2024-01-15"                 # date string β†’ epoch

Git & Dev Tools

ms branch "Fix: urgent bug"          # fix-urgent-bug, copied
echo "Feature Name" | ms branch      # stdin

ms run script.py                     # uv run
ms run app.js                        # node
ms run main.ts                       # deno run --allow-all
ms run main.go                       # go run
ms run script.py -- arg1 arg2        # pass arguments

ms filesize /path/to/file            # human-readable size, copied
ms filesize 1048576                  # 1.0 MB

ms regex '\d+' "abc123def456"        # match positions + capture groups
echo "long text" | ms regex '\w+'    # stdin for text

Color

ms color "#ff0000"                   # all formats (hex, rgb, hsl)
ms color "rgb(255,0,0)" hex          # β†’ #ff0000
ms color "hsl(0,100%,50%)" rgb       # β†’ rgb(255,0,0)

QR Code

ms qr "https://example.com"          # ASCII QR code in terminal
echo "hello" | ms qr                 # stdin

JWT

ms jwt "eyJhbGci..."                 # decode header + payload, show expiration

HTTP (feature: http)

ms http GET https://httpbin.org/get
ms http POST https://httpbin.org/post '{"key":"value"}'
ms http PUT https://api.example.com/resource '{"updated":true}'
ms http DELETE https://api.example.com/resource/1

Database (feature: db)

ms db "postgres://user:pass@localhost:5432/mydb"
# Interactive SQL session with CSV output
# sql> SELECT * FROM users LIMIT 3;
# sql> exit

File Diff

ms diff file1.txt file2.txt          # colored unified diff

Networking

ms ip                                # local + public IP
ms ip local                          # local only
ms ip public                         # public only

ms port check 8080                   # OPEN or CLOSED
ms port listen 8080                  # listen for connections (Ctrl+C to stop)

Cron

ms cron "*/5 * * * *"                # "At every 5 minutes of every hour"
ms cron "0 9 * * 1"                  # "At minute 0, hour 9, on Monday"

Environment Files

ms env .env                          # display with sensitive values masked
# API_KEY=sk******* (red)
# DATABASE_URL=postgres://... (cyan)

Shell Completions & Man Page

ms completions zsh >> ~/.zfunc/_ms   # generate completions
ms completions bash                  # bash completions
ms completions fish                  # fish completions
ms manpage > ms.1                    # generate man page

Architecture

Auto-discovery module system β€” create a directory in src/modules/ with a mod.rs implementing ToolModule and it's automatically registered at build time. No manual wiring needed.

src/
β”œβ”€β”€ main.rs              # subcommand dispatch
β”œβ”€β”€ error.rs             # MsError + MsResult
β”œβ”€β”€ tool_module.rs       # ToolModule trait
β”œβ”€β”€ module_registry.rs   # auto-generated registry
β”œβ”€β”€ util/
β”‚   β”œβ”€β”€ clipboard.rs     # copy_and_print helpers
β”‚   └── stdin.rs         # stdin detection + reading
└── modules/
    β”œβ”€β”€ base64/          β”œβ”€β”€ jwt/
    β”œβ”€β”€ case_convert/    β”œβ”€β”€ http/
    β”œβ”€β”€ checksum/        β”œβ”€β”€ diff/
    β”œβ”€β”€ color_convert/   β”œβ”€β”€ convert/
    β”œβ”€β”€ convert_to_branch/ β”œβ”€β”€ epoch/
    β”œβ”€β”€ cron/            β”œβ”€β”€ ip/
    β”œβ”€β”€ date/            β”œβ”€β”€ inspect/
    β”œβ”€β”€ db_connect/      β”œβ”€β”€ port/
    β”œβ”€β”€ env/             β”œβ”€β”€ url/
    β”œβ”€β”€ file_size/       β”œβ”€β”€ uuid_generate/
    β”œβ”€β”€ flatten_text/    β”œβ”€β”€ qr_generate/
    β”œβ”€β”€ hash/            β”œβ”€β”€ regex_test/
    β”œβ”€β”€ json/            β”œβ”€β”€ run_file/
    └── password_gen/

Adding a Module

// src/modules/my_tool/mod.rs
use crate::error::MsResult;
use crate::tool_module::ToolModule;
use clap::{ArgMatches, Command};

pub struct MyToolModule;

impl ToolModule for MyToolModule {
    fn name(&self) -> &'static str { "my-tool" }

    fn command(&self) -> Command {
        Command::new("my-tool")
            .about("Does something useful")
    }

    fn execute(&self, matches: &ArgMatches) -> MsResult<()> {
        // implementation
        Ok(())
    }
}

Build. Done. It's discovered automatically.

Development

cargo test --all-features             # 160 tests (127 unit + 33 integration)
cargo clippy --all-features -- -D warnings
cargo fmt
cargo build --release --all-features

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages