Skip to main content

Shell utilities for tmux, git, and command management

Project description

dkdc-sh

GitHub Release crates.io PyPI CI License: MIT

Shell library.

Install

cargo add dkdc-sh
uv add dkdc-sh

Usage

Rust

use dkdc_sh::{which, require, run, run_with_env, tmux, git};

// Command checking
if which("tmux").is_some() { /* ... */ }
require("git")?;

// Run arbitrary commands
let output = run("echo", &["hello"])?;

// Run with custom environment variables
let output = run_with_env("cargo", &["build"], &[("RUSTFLAGS", "-D warnings")])?;

// Tmux session management
tmux::new_session("my-service", "python server.py")?;
tmux::send_keys("my-service", "reload")?;
let logs = tmux::capture_pane("my-service", Some(50))?;
tmux::kill_session("my-service")?;

// Git operations
git::clone_shallow("https://github.com/org/repo.git", &dest, "main")?;
git::clone_shallow_with_env(
    "https://github.com/org/repo.git", &dest, "main",
    &[("GIT_SSH_COMMAND", "ssh -i ~/.ssh/deploy_key")],
)?;
git::checkout_new_branch(&repo_dir, "feature/branch")?;
git::config_set(&repo_dir, "user.email", "bot@example.com")?;
let log = git::cmd_with_env(&repo_dir, &["log", "--oneline"], &[("GIT_PAGER", "cat")])?;

Python

import dkdc_sh

# Command checking
path = dkdc_sh.which("tmux")
dkdc_sh.require("git")

# Run commands
output = dkdc_sh.run("echo", ["hello"])

# Run with custom environment variables
output = dkdc_sh.run("cargo", ["build"], env=[("RUSTFLAGS", "-D warnings")])

# Tmux
dkdc_sh.tmux_new_session("my-service", "python server.py")
dkdc_sh.tmux_send_keys("my-service", "reload")
logs = dkdc_sh.tmux_capture_pane("my-service", lines=50)
dkdc_sh.tmux_kill_session("my-service")

# Git
dkdc_sh.git_clone_shallow("https://github.com/org/repo.git", "./dest", "main")
dkdc_sh.git_checkout_new_branch("./repo", "feature/branch")
output = dkdc_sh.git_cmd("./repo", ["log", "--oneline"])

Error handling

Rust

The library uses a unified Error enum:

Variant Description
CommandNotFound Command not found in PATH
CommandFailed Non-zero exit code (includes stderr)
Tmux Tmux-specific errors
Io IO errors

Python

All errors are raised as RuntimeError.

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

dkdc_sh-0.2.1.tar.gz (9.9 kB view details)

Uploaded Source

Built Distributions

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

dkdc_sh-0.2.1-cp311-abi3-manylinux_2_39_x86_64.whl (296.9 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.39+ x86-64

dkdc_sh-0.2.1-cp311-abi3-manylinux_2_39_aarch64.whl (287.9 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.39+ ARM64

dkdc_sh-0.2.1-cp311-abi3-macosx_11_0_arm64.whl (252.8 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

dkdc_sh-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl (261.1 kB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file dkdc_sh-0.2.1.tar.gz.

File metadata

  • Download URL: dkdc_sh-0.2.1.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dkdc_sh-0.2.1.tar.gz
Algorithm Hash digest
SHA256 14233f5fee662fa23a7be09b47b8f73cd36db0221b88b40dc5e9a26ae037d8bf
MD5 f7aa6f46c998737dac1728923aacfee8
BLAKE2b-256 283a2def0e1949edc31430e7dff0a8244cb563c73dea4152521a7605ec219be6

See more details on using hashes here.

Provenance

The following attestation bundles were made for dkdc_sh-0.2.1.tar.gz:

Publisher: release-python.yml on dkdc-io/sh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dkdc_sh-0.2.1-cp311-abi3-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for dkdc_sh-0.2.1-cp311-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 8672bcc9e5e638a5ef08b7c7f5e82a09c767f300562f766369e090b19628a62f
MD5 8585a96b87b432fc27a7e64365b63f5a
BLAKE2b-256 43525a4e0d9ed6a5c933fe237761c763af9dc5f4e9072cf50628802e2b655f41

See more details on using hashes here.

Provenance

The following attestation bundles were made for dkdc_sh-0.2.1-cp311-abi3-manylinux_2_39_x86_64.whl:

Publisher: release-python.yml on dkdc-io/sh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dkdc_sh-0.2.1-cp311-abi3-manylinux_2_39_aarch64.whl.

File metadata

File hashes

Hashes for dkdc_sh-0.2.1-cp311-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 7325651ffae1ef3ccdbf8d8f56f87fd6e5fe43c7a9a3acf3b5861a556b991d4f
MD5 ecbd77325f1803cecbba76ee6838dff4
BLAKE2b-256 9ddc7033f6920c476cdb0f7a567514dda1e179bd2d16f9144cf52b455261b3f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for dkdc_sh-0.2.1-cp311-abi3-manylinux_2_39_aarch64.whl:

Publisher: release-python.yml on dkdc-io/sh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dkdc_sh-0.2.1-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dkdc_sh-0.2.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d779c01acd534ed0420cf608ef86d6f09f7aa50124ba2bb36511433255b3d228
MD5 967d94146676348cbdf9f4659ffe657b
BLAKE2b-256 589215bfd036cc5e7138d9449ab1d7aa8648141e3cd70e72cfe8784226875371

See more details on using hashes here.

Provenance

The following attestation bundles were made for dkdc_sh-0.2.1-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release-python.yml on dkdc-io/sh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dkdc_sh-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for dkdc_sh-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7d63f221f0b2da7f7777a1e63bda532edc6a89e10b2f2c40fcea7bb9e3041603
MD5 548c68519db3c88c196fba8d6e538d43
BLAKE2b-256 67b39ea0c12c32d35b63a4903b8a5f6f165e9af6b55bb979d5935dc8415a304f

See more details on using hashes here.

Provenance

The following attestation bundles were made for dkdc_sh-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl:

Publisher: release-python.yml on dkdc-io/sh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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