cli

rust
use clap::Parser;

#[derive(Parser, Debug)]
#[command(author, version, about)]
struct Args {
    #[arg(short, long)]

clap for CLI argument parsing with derive macros

rust cli clap
by Marcus Chen 1 tab
rust
use anyhow::{Context, Result};
use std::fs;

fn load_config(path: &str) -> Result<String> {
    fs::read_to_string(path)
        .with_context(|| format!("failed to read config from {}", path))

anyhow::Context for adding error context without custom types

rust error-handling cli
by Marcus Chen 1 tab
rust
use std::process::Command;

fn main() -> std::io::Result<()> {
    let output = Command::new("ls")
        .arg("-la")
        .output()?;

std::process::Command for spawning external processes

rust processes cli
by Marcus Chen 1 tab
python
import csv
from django.core.management.base import BaseCommand, CommandError
from products.models import Product, Category


class Command(BaseCommand):

Django custom management command for data import

django python cli
by Priya Sharma 1 tab
php
<?php

namespace App\Console\Commands;

use App\Models\User;
use App\Notifications\NewsletterEmail;

Laravel custom Artisan commands

laravel artisan commands
by Carlos Mendez 2 tabs
rust
use std::collections::HashMap;

#[derive(Debug, PartialEq)]
pub enum LogLevel {
    Info,
    Warn,

Streaming Log File Aggregation With Buffered Line Iteration in Rust

rust streaming file-io
by codesnips 3 tabs
go
package appconfig

import (
	"flag"
	"io"
	"os"

Parsing and Validating CLI Flags into a Typed Config Struct in Go

cli flags configuration
by codesnips 3 tabs
python
import errno
import fcntl
import os
import time

File-Based Locking to Prevent Concurrent Cron Job Runs in Python

locking concurrency fcntl
by codesnips 3 tabs
python
from dataclasses import dataclass


class ConfigError(Exception):
    pass

Typed Argparse Subcommands with Dataclasses and Handler Dispatch

argparse cli dataclasses
by codesnips 3 tabs
rust
use color_eyre::Result;

fn might_fail() -> Result<()> {
    Err(color_eyre::eyre::eyre!("Something went wrong"))
}

color-eyre for beautiful error reports with backtraces

rust error-handling cli
by Marcus Chen 1 tab