dekit

repository·master·Indexed 25 days ago

https://github.com/pvolok/dekit

A scriptable process manager (formerly mprocs) that runs multiple commands in parallel with separate output views and interactive management. It can be driven via CLI, TUI, API, or scripts, and supports configuration via YAML, npm scripts, or Procfiles. Features include remote control via TCP, OS-specific configuration using $select, and a native binary available via cargo and npm.

Tokens
9.4K
Snippets
16
Records
74
Agent score
83%

What's inside dekit

  1. Overview of mprocs (dekit)

    master

    mprocs (now renamed to dekit) is a tool that runs multiple commands in parallel and displays the output of each command separately. It allows you to switch between the outputs of running processes and interact with them (e.g., using editors like vim inside the process). It is an alternative to concurrently with better process interaction capabilities.

    Note: The legacy CLI is accessible via dekit mprocs ....

  2. Run mprocs processes via CLI or Config

    master

    You can run mprocs in two ways:

    1. Directly via CLI: Pass the commands you want to run as arguments. mprocs cmd1 cmd2 ...

    2. Via a configuration file: Create an mprocs.yaml file in your current directory and run mprocs.

    Example mprocs.yaml:

    procs:
      nvim:
        cmd: ["nvim"]
      server:
        shell: "nodemon server.js"
      webpack: "webpack serve"
      tests:
        shell: "jest -w"
        env:
          NODE_ENV: test
  3. Install mprocs (dekit)

    master

    You can install mprocs using several package managers depending on your platform:

    • npm: npm install -g mprocs or yarn global add mprocs
    • Homebrew (macOS/Linux): brew install mprocs
    • Cargo (All platforms): cargo install mprocs
    • Scoop (Windows): scoop install mprocs
    • AUR (Arch Linux): yay mprocs or yay mprocs-bin
    • Binary: Download the executable from the releases page and add it to your PATH.
    # npm
    npm install -g mprocs
    
    # homebrew
    brew install mprocs
    
    # cargo
    cargo install mprocs
    
    # scoop
    scoop install mprocs
    
    # AUR
    yay mprocs
  4. Run mprocs with package.json scripts or Procfile

    master

    mprocs provides specialized modes for common project files:

    • npm scripts: Use mprocs --npm to load scripts from package.json. Scripts are not started automatically; you must launch them manually.
    • Procfile: Use mprocs --procfile [PATH] to load processes from a Procfile. The default path is ./Procfile.
    • Autostart on Procfile: Use mprocs --procfile --on-init '{c: restart-all}' to start all processes in a Procfile immediately upon initialization.
    mprocs --npm
    
    mprocs --procfile ./Procfile.dev
    
    mprocs --procfile --on-init '{c: restart-all}'
  5. Configure mprocs (Global vs Local)

    master

    mprocs supports two levels of configuration:

    • Global config: Loaded from ~/.config/mprocs/mprocs.yaml (Linux/macOS) or ~\AppData\Roaming\mprocs\mprocs.yaml (Windows).
    • Local config: Loaded from mprocs.yaml in the current directory. You can also specify a custom path using the --config flag.

    Note: Settings in the local config override settings in the global config. The procs key is only allowed in local configurations.

    mprocs --config ./cfg/mprocs.yaml
  6. Set up a readiness probe with ready_log

    master
    A task can be configured to report as 'ready' only after a specific string appears in its output. Set the ready_log field in ProcessTaskConfig to a Some(String) containing the pattern. The task will transition to ReadyMode::Reported once the pattern is matched in a completed output line.
  7. Use the $select operator for OS-specific configuration

    master

    You can define different values based on the operating system using the $select operator. This is useful for handling differences between Windows, macOS, and Linux.

    Example mprocs.yaml:

    procs:
      my process:
        shell:
          $select: os
          windows: "echo %TEXT%"
          $else: "echo $TEXT"
        env:
          TEXT:
            $select: os
            windows: Windows
            linux: Linux
            macos: Macos
            freebsd: FreeBSD
    procs:
      my process:
        shell:
          $select: os
          windows: "echo %TEXT%"
          $else: "echo $TEXT"
        env:
          TEXT:
            $select: os
            windows: Windows
            linux: Linux
            macos: Macos
            freebsd: FreeBSD
  8. Use Remote Control to manage mprocs

    master

    mprocs can listen on a TCP port for remote commands.

    1. Enable Remote Control: Define a server address in mprocs.yaml (server: 127.0.0.1:4050) or via CLI (mprocs --server 127.0.0.1:4050).
    2. Send Commands: Use the --ctl argument with YAML-encoded commands.

    Common Commands:

    • {c: quit}: Stop processes and quit.
    • {c: restart-all}: Restart all processes.
    • {c: add-proc, cmd: "ls", name: "list"}: Add a new process.
    • {c: send-key, key: "<C-c>"}: Send a key to the current process.
    • {c: batch, cmds: [{c: focus-procs}, {c: next-proc}]}: Execute multiple commands.
  9. Configure a Process Task with ProcessTaskConfig

    master
    Use ProcessTaskConfig to define how a process task behaves, including its execution specification, termination signals, logging, and readiness criteria. You can initialize a default configuration using ProcessTaskConfig::new(spec) and then override specific fields.
  10. Default Keybindings for mprocs

    master

    Process List Focused

    • q / Q: Quit (soft) / Force quit
    • x / X: Soft kill / Hard kill selected process
    • s: Start selected process
    • r / R: Soft kill and restart / Hard kill and restart
    • a: Add new process
    • d: Remove selected process
    • e: Rename selected process
    • k / j (or / ): Navigate list
    • v: Enter copy mode
    • z: Zoom into terminal window

    Copy Mode

    1. Press v to enter copy mode.
    2. Move cursor to the start of text.
    3. Press v to start selection.
    4. Move cursor to the end of text.
    5. Press c to copy to clipboard.
    6. Press Esc to leave.