{"id":22822591,"url":"https://github.com/manighazaee/rngstr","last_synced_at":"2025-04-23T03:45:31.431Z","repository":{"id":236799684,"uuid":"793188673","full_name":"ManiGhazaee/rngstr","owner":"ManiGhazaee","description":"A cli tool for generating random strings of characters with customization options and a small domain specific language","archived":false,"fork":false,"pushed_at":"2024-05-30T15:43:50.000Z","size":63,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T03:45:28.311Z","etag":null,"topics":["cli","command-line","command-line-tool","domain-specific-language","random","rust","string","tool"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/ManiGhazaee.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":"2024-04-28T17:15:15.000Z","updated_at":"2025-04-04T15:55:46.000Z","dependencies_parsed_at":"2024-12-12T16:12:37.565Z","dependency_job_id":"bcceda37-5e41-4ebd-8ef0-39c71bae1279","html_url":"https://github.com/ManiGhazaee/rngstr","commit_stats":null,"previous_names":["manighazaee/rngstr"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManiGhazaee%2Frngstr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManiGhazaee%2Frngstr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManiGhazaee%2Frngstr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManiGhazaee%2Frngstr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ManiGhazaee","download_url":"https://codeload.github.com/ManiGhazaee/rngstr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250366678,"owners_count":21418768,"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":["cli","command-line","command-line-tool","domain-specific-language","random","rust","string","tool"],"created_at":"2024-12-12T16:12:28.681Z","updated_at":"2025-04-23T03:45:31.408Z","avatar_url":"https://github.com/ManiGhazaee.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rngstr\r\n\r\nA cli tool for generating random strings of characters with customization options and a small domain specific language.\r\n\r\n## Table of Contents\r\n- [Installation](#installation)\r\n- [Usage](#usage)\r\n  - [Options](#options)\r\n  - [Defaults](#defaults)\r\n- [Examples](#examples)\r\n- [DSL Usage](#dsl-usage)\r\n  - [Procedure Declaration](#procedure-declaration)\r\n    - [Command](#command)\r\n    - [Macro](#macro)\r\n  - [Procedure Call](#procedure-call)\r\n    - [Built-ins](#built-ins)\r\n- [DSL Examples](#dsl-examples)\r\n\r\n## Installation\r\n\r\n```bash \r\ncargo install rngstr\r\n```\r\n\r\n## Usage \r\n\r\n```bash\r\nrngstr [OPTIONS]\r\n```\r\n\r\n## Options\r\n- `-l, --length \u003cLENGTH\u003e`:\r\n\r\n- `-c, --custom \u003cCUSTOM\u003e`:\r\n          Specify a string of custom characters (e.g. `abc01111`)\r\n\r\n- `--regex \u003cREGEX\u003e`:\r\n          Specify a regular expression pattern to be used to generate the character set (e.g. `[0-9A-F]` will generate `0123456789ABCDEF` character set)\r\n\r\n- `-g, --group \u003cGROUP\u003e...`:\r\n          Specify a group of strings (e.g. \"foo\" \"bar\" \"baz\" will generate \"bar\")\r\n\r\n- `-p, --prefix \u003cPREFIX\u003e`:\r\n          Specify a string to be prepended to the generated string\r\n\r\n- `-s, --suffix \u003cSUFFIX\u003e`:\r\n          Specify a string to be appended to the generated string\r\n\r\n- `-r, --repeat \u003cREPEAT\u003e`:\r\n          Specify number of times string should be generated\r\n\r\n- `-d, --dsl \u003cDSL\u003e...`:\r\n          Specify path of the source file as first argument and optional path of destination file as second argument (it will print to terminal if not specified) \r\n\r\n- `--no-copy`:\r\n          Don't copy the generated result to clipboard\r\n\r\n- `--no-print`:\r\n          Don't print the generated result\r\n\r\n- `--password`:\r\n          Use the password character set (A-Z, a-z, 0-9, and special characters)\r\n\r\n- `-t, --trailing-suffix`:\r\n          Set trailing suffix generation to true\r\n\r\n- `-h, --help`:\r\n          Print help (see a summary with '-h')\r\n\r\n- `-V, --version`:\r\n          Print version\r\n\r\n### Defaults:\r\n\r\nBy default, `rngstr` generates random strings with the following settings:\r\n\r\n- character set = `[A-Za-z0-9]`\r\n- length = `0`\r\n- copy to clipboard = `true`\r\n- print = `true`\r\n- suffix = `\"\"`\r\n- prefix = `\"\"`\r\n- repeat = `1`\r\n\r\n## Examples\r\n\r\n```bash\r\nrngstr --regex [0-9a-z] -l 8 -s \", \" -r 3 \r\n```\r\n```bash\r\nln4hc1fk, srr9p704, ono7y09k \r\n```\r\n\r\n---\r\n\r\n```bash\r\nrngstr --range 0..60 -s \", \" -r 8 --trailing-suffix\r\n```\r\n```bash\r\n6, 2, 5, 41, 33, 25, 3, 21,\r\n```\r\n\r\n---\r\n\r\n```bash\r\nrngstr -c 0001 -l 8 -p \"0b\" -s \" \" -r 3 \r\n```\r\n```bash\r\n0b00000010 0b01100010 0b00001000\r\n```\r\n\r\n## DSL Usage\r\n\r\n### Procedure Declaration\r\n\r\n#### Command\r\n\r\nBasic:\r\n```\r\n!\u003cname\u003e: [OPTIONS]\r\n```\r\n\r\nExample:\r\n\r\n```\r\n!foo: --regex [0-9] -l 8\r\n```\r\n\r\nWith parameters:\r\n\r\n```\r\n!\u003cname\u003e\u003cparameters...\u003e: [OPTIONS]\r\n```\r\n\r\nExample:\r\n\r\n```\r\n!foo\u003cstart, end\u003e: --range start..end\r\n```\r\n\r\n#### Macro\r\n\r\nBasic:\r\n\r\n```\r\n!\u003cname\u003e:(\u003ctext\u003e) \r\n```\r\n\r\nExample:\r\n\r\n```\r\n!foo:(!bar())\r\n```\r\n\r\nWith parameters:\r\n\r\n```\r\n!\u003cname\u003e\u003cparameters...\u003e:(\u003ctext\u003e)\r\n```\r\n\r\nExample:\r\n\r\n```\r\n!foo\u003cx, y, z\u003e:(!bar\u003cz\u003e() !baz\u003cx, y\u003e()) \r\n```\r\n\r\n### Procedure Call\r\n\r\nAfter the first non-declaration line (a trimmed line not starting with `!`), you can call the declared procedure using the following syntax:\r\n\r\nBasic:\r\n\r\n```\r\n!\u003cname\u003e()\r\n```\r\n\r\nExample:\r\n\r\n```\r\n!foo()\r\n```\r\n\r\nWith placeholder `$`:\r\n\r\n```\r\n!\u003cname\u003e($)\r\n```\r\n\r\nExample:\r\n\r\n```\r\n!foo($)\r\n```\r\n\r\nYou can also use multiple placeholders within a call, where each `$` will generate the same string:\r\n\r\nExample:\r\n\r\n```\r\n!foo: -c 012 -l 4\r\n-\r\n!foo($ $ $ $)\r\n```\r\n\r\nOutput:\r\n```\r\n-\r\n2211 2211 2211 2211\r\n```\r\n\r\nWith arguments seperated by `,`:\r\n\r\n```\r\n!\u003cname\u003e\u003carguments...\u003e()\r\n```\r\n\r\nExample:\r\n\r\n```\r\n!foo\u003cx, y, z\u003e()\r\n```\r\n\r\n---\r\n\r\nIf we call the substring after the first `:` in the procedure declaration procedure body, each occurrence of parameters inside the procedure body is replaced by parsed arguments in the procedure call. It is possible to pass the name of a procedure as an argument and call it inside the procedure body:\r\n\r\nExample:\r\n\r\n```\r\n!array\u003cprocedure, length\u003e:([!repeat\u003clength, \", \"\u003e(!procedure())])\r\n!foo: --regex [a-z0-9] -l 8\r\n!foo_str:(\"!foo()\")\r\n\r\n{\r\n    \"array\": !array\u003cfoo_str, 4\u003e()\r\n}\r\n```\r\n\r\nOutput:\r\n\r\n```\r\n{\r\n    \"array\": [\"2r4xtqv0\", \"t9na5pn0\", \"p1nbqvra\", \"c6hhww19\"]\r\n}\r\n```\r\n\r\nOr:\r\n\r\n```\r\n{\r\n    \"array\": !array\u003carray\u003carray\u003cfoo_str, 2\u003e, 2\u003e, 2\u003e()\r\n}\r\n```\r\n\r\nOutput:\r\n\r\n```\r\n{\r\n    \"array\": [[[\"mw4kghh2\", \"qk2htxp2\"], [\"4s7g0z9n\", \"a1cszc89\"]], [[\"xlcyhv4x\", \"ds4b351r\"], [\"pylnsvuu\", \"kny0h3a3\"]]]\r\n}\r\n```\r\n\r\n#### Built-ins\r\n\r\nThese procedures are usable by calling with their name and overwritable by declaraing another procedure with their name.\r\n\r\n**`cmd\u003cstring\u003e`**\r\n\r\nExecutes a command and returns the result.\r\n\r\nExample:\r\n\r\n```\r\n!cmd\u003c\"--group foo bar baz\"\u003e()\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nfoo\r\n```\r\n\r\n---\r\n\r\n**`repeat\u003ccount, suffix\u003e`**\r\n\r\nRepeats a procedure a specified number of times, with each result separated by a given suffix.\r\n\r\nExample:\r\n\r\n```\r\n!repeat\u003c4, \", \"\u003e(!cmd\u003c\"--range 0..100\"\u003e())\r\n```\r\n\r\nOutput: \r\n\r\n```\r\n23, 67, 4, 91\r\n```\r\n\r\n---\r\n\r\n**`array\u003cprocedure, length\u003e`**\r\n\r\nCreates an array by repeating a procedure a specified number of times.\r\n\r\nExample:\r\n\r\n```\r\n!array\u003cusize\u003c0, 100\u003e, 5\u003e()\r\n```\r\n\r\nOutput:\r\n\r\n```\r\n[23, 67, 4, 91, 45]\r\n```\r\n\r\n---\r\n\r\n**`array_fill\u003celement, length\u003e`**\r\n\r\nCreates an array filled with a specified element repeated a specified number of times.\r\n\r\nExample:\r\n\r\n```\r\n!array_fill\u003c42, 5\u003e()\r\n```\r\n\r\nOutput:\r\n\r\n```\r\n[42, 42, 42, 42, 42]\r\n```\r\n\r\n\r\n---\r\n\r\n**`!id\u003ctag\u003e`**\r\n\r\nAdds an entry in a hashmap with the tag as the key and 0 as the initial value, incrementing it on each call. Due to parallel parsing, the numbers are not generated in order.\r\n\r\nExample:\r\n\r\n```\r\n!array\u003cid\u003ca\u003e, 10\u003e()\r\n!array\u003cid\u003cb\u003e, 10\u003e()\r\n!array\u003cid\u003ca\u003e, 10\u003e()\r\n```\r\n\r\nOutput:\r\n\r\n```\r\n[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\r\n[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\r\n[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\r\n```\r\n\r\n---\r\n\r\n**`!group\u003citems...\u003e`**\r\n\r\nRandomly returns one of the specified items\r\n\r\nExample:\r\n\r\n```\r\n!group\u003cfoo, bar, baz\u003e()\r\n!group\u003cfoo, bar, baz\u003e()\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nfoo\r\nbaz\r\n```\r\n\r\n---\r\n\r\n**Number Types**\r\n\r\nAll Rust number types are supported for generating random values within a range or without a specified range:\r\n\r\nExample:\r\n\r\n```\r\n[!u8\u003c0, 10\u003e(), !u16\u003c0, 10\u003e(), !u32\u003c0, 10\u003e(), !u64\u003c0, 10\u003e(), !u128\u003c0, 10\u003e(), !i8\u003c0, 10\u003e(), !i16\u003c0, 10\u003e(), !i32\u003c0, 10\u003e(), !i64\u003c0, 10\u003e(), !i128\u003c0, 10\u003e(), !f32\u003c0, 10\u003e(), !f64\u003c0, 10\u003e(), !usize\u003c0, 10\u003e(), !isize\u003c0, 10\u003e(), !id\u003c0\u003e()]\r\n[!u8(), !u16(), !u32(), !u64(), !u128(), !i8(), !i16(), !i32(), !i64(), !i128(), !f32(), !f64(), !usize(), !isize()]\r\n```\r\n\r\nOuput:\r\n\r\n```\r\n[3, 7, 4, 8, 9, 4, 7, 3, 1, 4, 6.409465, 1.9037502953455854, 3, 5, 0]\r\n[169, 8026, 3981710656, 15859526283082379939, 294250989955636718152642071911969640664, 114, -11975, 862154430, -650703279019604957, 104795060125221781861534722358106096176, 0.46059388, 0.8589771759897691, 13709073818113593800, 5359762487833681572]\r\n```\r\n\r\n## DSL Examples\r\n\r\n```bash\r\nrngstr --dsl foo.txt bar.json \r\n```\r\nfoo.txt\r\n```\r\n!foo: --regex [0-9A-Z] -l 8 -s \",\\n    \"  -r 9\r\n!bar: --range 0..99         -s \", \"       -r 4\r\n\r\n{\r\n    !foo(\"$\": {\r\n        \"_$_\": [!bar()]\r\n    })\r\n}\r\n```\r\nbar.json\r\n```json\r\n{\r\n    \"H3IM3O66\": {\r\n        \"_H3IM3O66_\": [67, 86, 36, 61]\r\n    },\r\n    \"QHZB5NMC\": {\r\n        \"_QHZB5NMC_\": [49, 24, 93, 77]\r\n    },\r\n    \"JK2MSTAU\": {\r\n        \"_JK2MSTAU_\": [85, 86, 41, 56]\r\n    },\r\n    \"GZA0V753\": {\r\n        \"_GZA0V753_\": [23, 19, 93, 24]\r\n    },\r\n    \"79XOI38K\": {\r\n        \"_79XOI38K_\": [57, 61, 41, 3]\r\n    },\r\n    \"0U2H5RLP\": {\r\n        \"_0U2H5RLP_\": [75, 72, 73, 63]\r\n    },\r\n    \"8DLY976J\": {\r\n        \"_8DLY976J_\": [88, 38, 3, 64]\r\n    },\r\n    \"5PU1MQW3\": {\r\n        \"_5PU1MQW3_\": [72, 27, 4, 30]\r\n    },\r\n    \"IVG57ISE\": {\r\n        \"_IVG57ISE_\": [17, 37, 9, 43]\r\n    }\r\n}\r\n```\r\n\r\n---\r\n\r\nfoo.txt\r\n```\r\n!foo_group:(foo, bar, baz)\r\n!dq\u003cproc\u003e:(\"!proc()\")\r\n\r\n{\r\n    \"group\": !array\u003cdq\u003cgroup\u003c!foo_group()\u003e\u003e, 5\u003e()\r\n}\r\n```\r\nbar.json\r\n```\r\n{\r\n    \"group\": [\"foo\", \"baz\", \"bar\", \"foo\", \"foo\"]\r\n}\r\n```\r\n\r\n---\r\n\r\n```bash\r\nrngstr --dsl foo.txt bar.ron\r\n```\r\nfoo.txt\r\n```\r\n!str:(\"!cmd\u003c--regex [a-z] -l !usize\u003c3, 9\u003e()\u003e()\")\r\n!rgba:(Rgba(!repeat\u003c4, \", \"\u003e(!u8())))\r\n!ida:(\"a!id\u003ca\u003e()\")\r\n!bool:(!group\u003ctrue, false\u003e())\r\n\r\n( \r\n    foo: {\r\n        !repeat\u003c5, \",\\n\\t\\t\"\u003e(!str(): (\r\n            x: !f32(),\r\n        ))\r\n    },\r\n    bar: [\r\n        !repeat\u003c5, \",\\n\\t\\t\"\u003e((\r\n            t: !rgba(),\r\n            u: !ida(),\r\n            v: !bool(),\r\n        ))\r\n    ],\r\n)\r\n```\r\nbar.ron\r\n```\r\n( \r\n    foo: {\r\n        \"dxpln\": (\r\n            x: 0.7885895,\r\n        ),\r\n        \"yaqdg\": (\r\n            x: 0.48093498,\r\n        ),\r\n        \"hungukuf\": (\r\n            x: 0.9161161,\r\n        ),\r\n        \"qtfnkeve\": (\r\n            x: 0.9836798,\r\n        ),\r\n        \"dqedis\": (\r\n            x: 0.42920595,\r\n        )\r\n    },\r\n    bar: [\r\n        (\r\n            t: Rgba(217, 101, 149, 83),\r\n            u: \"a0\",\r\n            v: true,\r\n        ),\r\n        (\r\n            t: Rgba(209, 48, 76, 67),\r\n            u: \"a1\",\r\n            v: true,\r\n        ),\r\n        (\r\n            t: Rgba(62, 167, 240, 81),\r\n            u: \"a2\",\r\n            v: false,\r\n        ),\r\n        (\r\n            t: Rgba(251, 139, 57, 219),\r\n            u: \"a3\",\r\n            v: false,\r\n        ),\r\n        (\r\n            t: Rgba(146, 106, 246, 52),\r\n            u: \"a4\",\r\n            v: false,\r\n        )\r\n    ],\r\n)\r\n```\r\n\r\n---\r\n\r\n```bash\r\nrngstr --dsl foo.txt bar.txt \r\n```\r\nfoo.txt\r\n```\r\n!foo: --regex [0-2] -l 4 \r\n!bar: --regex [7-9] -l 4\r\n1: !foo()\r\n2: !foo($)\r\n3: !foo($ !foo())\r\n4: !foo($ !bar())\r\n5: !foo($ !bar($))\r\n6: !foo(\\$ !bar($))\r\n7: \\!foo($ !bar($))\r\n8: \\!foo($ \\!bar($))\r\n```\r\nbar.txt\r\n```\r\n1: 2220\r\n2: 0101\r\n3: 0020 2201\r\n4: 2022 9777\r\n5: 0220 7879\r\n6: $ 8897\r\n7: !foo($ 7988)\r\n8: !foo($ !bar($))\r\n```\r\n\r\n---\r\n\r\n```bash\r\nrngstr --dsl foo.txt bar.txt\r\n```\r\nfoo.txt\r\n```\r\n!foo: -c 012 -l 4 \r\n!r4:  -r 4 -s \"\\\"\" \r\n\r\n1: !foo() !foo() !foo() !foo()\r\n2: !foo($ $ $ $)\r\n3: !foo( abcd )\r\n4: !r4(!foo())\r\n5: !r4($ $ $ $)\r\n6: !foo(!foo(!foo(!foo())))\r\n7: !foo($ !foo($ !foo($ !foo())))\r\n```\r\nbar.txt\r\n```\r\n1: 1122 0212 1222 0202\r\n2: 2211 2211 2211 2211\r\n3: 0021 abcd \r\n4: 2021\"1212\"2201\"1110\r\n5:    \"   \"   \"   \r\n6: 0002\r\n7: 0112 1220 2022 0201\r\n```\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanighazaee%2Frngstr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanighazaee%2Frngstr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanighazaee%2Frngstr/lists"}