{"id":16592521,"url":"https://github.com/jakestanger/stamp","last_synced_at":"2025-10-29T10:30:30.810Z","repository":{"id":57668523,"uuid":"266626593","full_name":"JakeStanger/stamp","owner":"JakeStanger","description":"A command line tool for creating one or more files from templates, written in Rust.","archived":false,"fork":false,"pushed_at":"2020-05-26T13:43:29.000Z","size":59,"stargazers_count":4,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-08T15:06:13.867Z","etag":null,"topics":["cli","handlebars","rust","template"],"latest_commit_sha":null,"homepage":null,"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/JakeStanger.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}},"created_at":"2020-05-24T21:18:24.000Z","updated_at":"2021-08-25T15:51:42.000Z","dependencies_parsed_at":"2022-08-27T03:24:59.858Z","dependency_job_id":null,"html_url":"https://github.com/JakeStanger/stamp","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeStanger%2Fstamp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeStanger%2Fstamp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeStanger%2Fstamp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeStanger%2Fstamp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JakeStanger","download_url":"https://codeload.github.com/JakeStanger/stamp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238803493,"owners_count":19533328,"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","handlebars","rust","template"],"created_at":"2024-10-11T23:21:13.101Z","updated_at":"2025-10-29T10:30:30.476Z","avatar_url":"https://github.com/JakeStanger.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stamp\n\n![Rust](https://github.com/JakeStanger/stamp/workflows/Pipeline/badge.svg)\n\nA command line tool for creating one or more files from templates, written in Rust.\n\nStamp was born out of a lack of tooling that filled this middle ground:\n\n- IntelliJ supports creating files from templates, but only one file at a time.\n- Tools like Cookiecutter and Yeoman are slow and far too large for quick usage.\n\n## Installation\n\nYou will require rust and cargo installed.\n\n```bash\ncargo install stampr\n```\n\nAnnoyingly the crate name `stamp` was already taken.\n\nYou might want to `alias stamp=stampr`.\n\n## Usage\n\n### Command Line Usage\n\nCommand line help can be viewed using `stampr -h` or `stampr --help` for more detail.\n\nYou can also use `stampr help \u003ccommand\u003e`.\n\n#### List\n\n`stampr list` will show a list of installed templates. \nPassing the `-v` flag will also show the path of each template on disk.\n\n#### Run\n\n`stampr run \u003ctemplate\u003e` will render a template and create the files.\n\nBy default, files are written relative to your current working directory. \nTo change this, use `-o` or `--out`. \nIf the path does not exist, it will be created for you.\n\nArguments for a template can be specified using the `-c` or `--context` flag, \nand provided in `key=value` pairs. \nAny arguments not provided will prompt you for input.\nThis must be the last flag provided.\n\nExample:\n\n```bash\nstampr run test --out /tmp/stamp-test -c greeting=Hello subject=World\n```\n\n### Creating Templates\n\n#### Locations\n\nTemplates can be stored globally or inside a directory. When looking for templates, Stamp will:\n- Look for a `.stamp/templates` folder inside the current directory\n- Recurse up each parent directory, looking for the same folder\n- Check the global directory\n\nIf multiple templates of the same name exist, the first one found is used. \nThis means it is possible to include templates in your repository, \nand to override global templates by creating one of the same name inside a folder.\n\nGlobal templates are stored inside the current user's configuration folder.\n\n- Linux: `~/.config/stamp/templates`\n- OSX: `$USER/Library/Preferences/stamp`\n- Windows: `%appdata%\\stamp\\templates`\n\n#### Files\n\nTo create a template, simply create a directory with the template name in a templates folder.\n\nEach file and folder inside that directory is then templated. \nThe file name and contents are rendered using [Handlebars](https://handlebarsjs.com/guide/).\nA number of helpers are available, and the list can be found [here](https://github.com/davidB/handlebars_misc_helpers/tree/v0.9.0).\n\nVariables used in templates are automatically detected and turned into arguments at runtime.\n\n#### Example\n\nOne such use-case might be to scaffold out a single TypeScript React component, \nincluding a file for the props and another for the stylesheet.\n\nThe end goal is to end up with this structure:\n```\ntestComponent\n├── ITestComponentProps.ts\n├── TestComponent.module.scss\n└── TestComponent.tsx\n```\n\nTo create the template, create a folder called `tsx-component` in a Stamp template folder.\n\nInside the template folder, create a new folder to house the component files.\nName it `{{to_camel_case name}}`. \nThis means the directory will always take the name argument and ensure it is in camelCase.\n\nInside that directory, create three files:\n\n- `{{to_pascal_case name}}.tsx`\n- `I{{to_pascal_case name}}Props.ts`\n- `{{to_pascal_case name}}.module.scss`\n\nThe first file houses imports for the other two, as well as a basic functional component:\n\n```tsx\nimport * as React from 'react';\nimport I{{to_pascal_case name}}Props from './I{{to_pascal_case name}}Props';\nimport styles from '{{to_pascal_case name}}.module.scss';\n\nconst {{to_pascal_case name}}: React.FC\u003cI{{to_pascal_case name}}Props\u003e = () =\u003e {\n  return \u003cspan /\u003e;\n};\n\nexport default {{to_pascal_case name}};\n```\n\nThe second contains a blank interface:\n\n```ts\ninterface I{{to_pascal_case name}}Props {\n\n}\n\nexport default I{{to_pascal_case name}}Props;\n```\n\nAnd the third can remain empty.\n\nNow run your template:\n```bash\nstampr run tsx-component -c name=testComponent\n```\n\nYou should see a directory created called `testComponent` with 3 files inside.\n\n\u003e Note it would be possible to avoid using the helpers above and just use `{{name}}` \n\u003eif you do not want causing to automatically be adjusted. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakestanger%2Fstamp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakestanger%2Fstamp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakestanger%2Fstamp/lists"}