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.2.tar.gz (10.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.2-cp311-abi3-manylinux_2_39_x86_64.whl (299.4 kB view details)

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

dkdc_sh-0.2.2-cp311-abi3-manylinux_2_39_aarch64.whl (289.8 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.39+ ARM64

dkdc_sh-0.2.2-cp311-abi3-macosx_11_0_arm64.whl (255.3 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

dkdc_sh-0.2.2-cp311-abi3-macosx_10_12_x86_64.whl (263.4 kB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for dkdc_sh-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4d895f3e0768c0cc7610e0b92b522aa3b548d25d43705f620a56fc7182c392e8
MD5 a49b425a33de1228bfcd39a36f1ecaba
BLAKE2b-256 f08335f60eeb1c220626804f3698802ed38040efe0615310d858f90edb3e3fc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for dkdc_sh-0.2.2.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.2-cp311-abi3-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for dkdc_sh-0.2.2-cp311-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 4a1d56bb11bdc5a71be792c2de273e52aa0a1c6a47aaeddf3fdf0efe991ea8a8
MD5 e6555d813ee7478af4bf25be1907484f
BLAKE2b-256 aba8309a47ad8d569c300828b271807f909fc49f279d883437b4480fe63d867d

See more details on using hashes here.

Provenance

The following attestation bundles were made for dkdc_sh-0.2.2-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.2-cp311-abi3-manylinux_2_39_aarch64.whl.

File metadata

File hashes

Hashes for dkdc_sh-0.2.2-cp311-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 83b5989c2a23b7293982ad707c9b4cb8db8ebc1da58ea40ded3aba089223ba3f
MD5 9bea43d333d64ab05931746ddb3a1d3d
BLAKE2b-256 a8b2aedebe34337667105211ccd1f1b3c6091e002702eaf3f62fc93429bfcc77

See more details on using hashes here.

Provenance

The following attestation bundles were made for dkdc_sh-0.2.2-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.2-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dkdc_sh-0.2.2-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0eaaf08eb432f861453dfbab08c8904e40b24810ff4b293514c004a490787b68
MD5 8eb31dc4721c6044c16db620a2976eab
BLAKE2b-256 9eb87e7f063034e77d86e0e951996691bc9b0511f24bdac9e9b420e5cb950050

See more details on using hashes here.

Provenance

The following attestation bundles were made for dkdc_sh-0.2.2-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.2-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for dkdc_sh-0.2.2-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f57406cae2a86e8324c83c104bfc7c496aabf9105e81b252e1e6055a9ae57fb6
MD5 d3a5022194307cc76dbae51464a16c99
BLAKE2b-256 318b197a45c4e29a24a11e00a7a2f5d7300e064a687c3acd52ec152ed4f004a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for dkdc_sh-0.2.2-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