{"id":26667100,"url":"https://github.com/joeycumines/randoo","last_synced_at":"2025-03-25T19:36:16.366Z","repository":{"id":278868961,"uuid":"937023827","full_name":"joeycumines/randoo","owner":"joeycumines","description":"randoo is a simple command-line utility written in Go that randomizes the order of command arguments before executing a given command","archived":false,"fork":false,"pushed_at":"2025-02-22T07:05:32.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T08:19:37.646Z","etag":null,"topics":["arguments","automation","cli","command-line","exec","go","randomization","shuffling","utility"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joeycumines.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-22T06:31:55.000Z","updated_at":"2025-02-22T07:04:07.000Z","dependencies_parsed_at":"2025-02-22T08:19:39.072Z","dependency_job_id":null,"html_url":"https://github.com/joeycumines/randoo","commit_stats":null,"previous_names":["joeycumines/randoo"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeycumines%2Frandoo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeycumines%2Frandoo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeycumines%2Frandoo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeycumines%2Frandoo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joeycumines","download_url":"https://codeload.github.com/joeycumines/randoo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245532623,"owners_count":20630959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arguments","automation","cli","command-line","exec","go","randomization","shuffling","utility"],"created_at":"2025-03-25T19:36:15.514Z","updated_at":"2025-03-25T19:36:16.354Z","avatar_url":"https://github.com/joeycumines.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# randoo\n\nrandoo is a simple command-line utility written in Go that randomizes the order of command arguments before executing a\ngiven command. It provides flexible options to control which arguments get shuffled, whether by shuffling all arguments\nor only a subset delimited by special tokens.\n\n---\n\n## Overview\n\nBy design, randoo:\n\n- **Shuffles arguments:** It randomizes the order of command arguments.\n- **Executes commands:** After shuffling, it calls the specified command with the randomized arguments.\n- **Offers selective shuffling:** You can control which arguments are shuffled using start (`-s`) and end (`-e`)\n  delimiters (consumed).\n- **Supports input from stdin:** With the `-l` flag, you can supply additional arguments via standard input (one per\n  line).\n\n---\n\n## Usage\n\n```bash\nrandoo [options] [--] command [args...]\n```\n\n- **command:** The executable you want to run.\n- **args...:** The arguments for the command, which will be randomized according to the options provided.\n\n---\n\n## Command-Line Options\n\n- **`-s string`**\n  *Shuffle args after the specified argument (start delimiter).*\n  The argument provided with this flag marks the beginning of the segment to be shuffled.\n  **Behavior:**\n    - The tool searches for this delimiter in the provided arguments.\n    - If found, the arguments after this token (or up to an end delimiter, if specified) are shuffled.\n    - The delimiter itself is not passed on to the command.\n    - **Error:** If the token is not found, randoo exits with an error.\n\n- **`-e string`**\n  *Shuffle args before the specified argument (end delimiter).*\n  This flag designates the end of the segment to be shuffled.\n  **Behavior:**\n    - The tool searches for this token.\n    - If found, the arguments preceding it (or a segment defined between a start and this end delimiter) are randomized.\n    - Like the start delimiter, this token is not passed on.\n    - **Error:** If the token is not found, an error is reported.\n\n- **`-l`**\n  *Read input from stdin, one argument per line.*\n  **Behavior:**\n    - Reads additional arguments from standard input.\n    - These arguments are appended to any trailing arguments (which are not shuffled unless affected by the delimiters).\n    - This is useful for dynamically supplying arguments at runtime.\n\n---\n\n## Implementation Details\n\n### Shuffling Logic\n\n- **Complete Shuffle:**\n  If neither `-s` nor `-e` is provided, all arguments are shuffled.\n\n- **Single Delimiter Mode:**\n  When only one of the delimiters is specified:\n    - For **`-s` only:** randoo finds the delimiter, removes it, and shuffles all arguments that follow.\n    - For **`-e` only:** It shuffles all arguments preceding the found delimiter and then removes the delimiter.\n\n- **Delimited Range Shuffle:**\n  If **both** `-s` and `-e` are provided:\n    - The program searches for the start delimiter (`-s`).\n    - It then looks for the end delimiter (`-e`) after the start delimiter.\n    - Only the arguments in between are shuffled.\n    - After shuffling, both delimiters are removed before execution.\n\n- **Random Source:**\n  randoo uses a custom random source based on `crypto/rand` to seed the shuffle mechanism, ensuring that the\n  randomization is well-seeded and secure.\n\n### Execution and Signal Handling\n\n- **Command Execution:**\n  After processing and shuffling the arguments, randoo executes a subprocess, with the provided command, and processed\n  arguments.\n\n- **Signal Forwarding:**\n  It sets up signal forwarding so that any signals received (like SIGINT) are passed to the spawned process, ensuring\n  proper signal handling during execution.\n\n- **Error Handling:**\n  The tool validates that:\n    - A command is provided.\n    - Required delimiters exist in the arguments (if specified).\n\n  In case of errors (e.g., missing command, missing delimiter), it outputs a relevant error message and exits with a\n  non-zero status. It also attempts to propagate the exit code of the executed command, when possible.\n\n---\n\n## Examples\n\n### 1. Basic Randomization\n\nShuffle all arguments before executing the command:\n\n```bash\nrandoo cat file1.txt file2.txt file3.txt\n```\n\nThis will shuffle the order of `file1.txt`, `file2.txt`, and `file3.txt` before concatenating them.\n\n### 2. Using a Single Delimiter\n\nShuffle only the arguments after a specified token:\n\n```bash\nrandoo -s START echo a b c START arg1 arg2 arg3\n```\n\nExample output: `a b c arg2 arg3 arg1`\n\n- **Behavior:**\n    - `START` is used as the start delimiter.\n    - The arguments following `START` (`arg1 arg2 arg3`) are shuffled.\n    - The delimiter is removed before executing the command.\n\n### 3. Using Both Delimiters\n\nShuffle a specific range of arguments:\n\n```bash\nrandoo -s START -e END echo a b c START arg1 arg2 arg3 END d e\n```\n\nExample output: `a b c arg2 arg3 arg1 d e`\n\n- **Behavior:**\n    - `START` marks the beginning and `END` marks the end of the segment to be shuffled.\n    - Only the arguments between `START` and `END` (`arg1 arg2 arg3`) are randomized.\n    - Both delimiters are stripped from the final command line.\n\n### 4. Reading Arguments from Stdin\n\nShuffle arguments provided via standard input:\n\n```bash\necho -e \"arg1\\narg2\\narg3\" | randoo -l mycommand\n```\n\n- **Behavior:**\n    - Reads each line from stdin as an argument.\n    - Shuffles the input arguments.\n    - Appends them to the command `mycommand` for execution.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeycumines%2Frandoo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoeycumines%2Frandoo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeycumines%2Frandoo/lists"}