{"id":13770219,"url":"https://github.com/pharo-contributions/clap-st","last_synced_at":"2025-09-24T01:25:11.496Z","repository":{"id":42051956,"uuid":"67039800","full_name":"pharo-contributions/clap-st","owner":"pharo-contributions","description":"Command-line argument parsing for Pharo","archived":false,"fork":false,"pushed_at":"2025-04-01T13:08:30.000Z","size":1786,"stargazers_count":35,"open_issues_count":10,"forks_count":9,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-07-22T20:42:24.494Z","etag":null,"topics":["command-line","command-line-parser","pharo","smalltalk"],"latest_commit_sha":null,"homepage":"","language":"Smalltalk","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pharo-contributions.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2016-08-31T13:27:32.000Z","updated_at":"2025-07-02T07:09:28.000Z","dependencies_parsed_at":"2023-12-14T15:28:00.108Z","dependency_job_id":"6fea0d2a-d51d-46ef-8e27-c06f8bba8e26","html_url":"https://github.com/pharo-contributions/clap-st","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/pharo-contributions/clap-st","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pharo-contributions%2Fclap-st","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pharo-contributions%2Fclap-st/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pharo-contributions%2Fclap-st/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pharo-contributions%2Fclap-st/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pharo-contributions","download_url":"https://codeload.github.com/pharo-contributions/clap-st/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pharo-contributions%2Fclap-st/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268400668,"owners_count":24244445,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["command-line","command-line-parser","pharo","smalltalk"],"created_at":"2024-08-03T17:00:35.344Z","updated_at":"2025-09-24T01:25:06.433Z","avatar_url":"https://github.com/pharo-contributions.png","language":"Smalltalk","funding_links":[],"categories":["Command line"],"sub_categories":[],"readme":"# CLAP — Command line argument parser for Pharo\n[![Build Status][travis-status]][travis]\n[![Coverage Status][coveralls-status]][coveralls]\n\nNamed after and inspired by [clap-rs](https://github.com/kbknapp/clap-rs), but\nthis is an independent implementation.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"/demos/clap.gif?raw=true\" width=\"640\" height=\"360\" alt=\"Terminal screencast demo\"/\u003e\n\u003c/p\u003e\n\nCLAP project is after major refactoring (due to needs raised by [PharoLauncher CLI](https://github.com/pharo-project/pharo-launcher/tree/feature/cmd-line/src/PharoLauncher-CLI)) and should be more stable now. It means main pieces are\nthere but some features are still missing and eventually may force changes in the design in rare cases.\n\n### Loading instructions\n\nPharo image already contains stable version of CLAP, but you can load latest version of project  by: \n\n```smalltalk\nMetacello new \n\tbaseline: 'Clap';\n    repository: 'github://pharo-contributions/clap-st/src';\n    load.\n```\n\n#### starting from the shell\n\n```shell\ngit clone https://github.com/pharo-contributions/clap-st.git\ncd clap-st\ncurl https://get.pharo.org/64/ | bash\n```\n\n…and then, in the image just downloaded, open a workspace and evaluate:\n\n```smalltalk\nMetacello new \n\tbaseline: 'Clap';\n   \trepository: 'gitlocal://./src';\n   \tload.\n```\n\nShameless plug: I work with [Fari](https://people.untyped.org/fari.sh) and\n[direnv](https://direnv.net) to automate building and launching the development image:\n\n```shell\n# setup $PHARO\nfari build\nfari run\n```\n\n### Defining and invoking commands\n\nCommands and subcommands (their specification) are instances of `#ClapCommandSpec`. To make a command\naccessible from the command line, return it from a class-side factory method\nwith the `\u003ccommandline\u003e` pragma. Such class-side method should be defined on user-defined subclass of `ClapApplication`. For instance, here's how we declare the\ntraditional *hello, world!* example, with the actual behavior delegated the\ninstance-side method `ClapCommandLineExamples \u003e\u003e sayHello`:\n\n```smalltalk\nhello\n\t\"The usual Hello-World example, demonstrating a Clap command with a couple features.\"\n\t\u003cscript\u003e\n\t\u003ccommandline\u003e\n\t^ (ClapCommandSpec id: #hello)\n\t\tdescription: 'Provides greetings';\n\t\tcommandClass: self;\n\t\taddHelp;\n\t\taddFlag: #whisper description: 'Greet discretely';\n\t\taddFlag: #shout description: 'Greet loudly';\n\t\taddFlag: #language \n\t\t\tdescription: 'Select language of greeting' \n\t\t\tpositionalSpec: [ :positional |\n\t\t\t\tpositional\n\t\t\t\t\tsymbol;\n\t\t\t\t\tdefaultValue: [ :arg :app | app defaultLanguage ] ];\n\t\taddPositional: #who spec: [ :positional |\n\t\t\tpositional\n\t\t\t\tdescription: 'Recipient of the greetings';\n\t\t\t\tmultiple: true;\n\t\t\t\tdefaultValue: [ :arg :app | { app defaultRecipient } ] ];\n\t\tyourself\n```\n\nFor now, CLAP installs itself as a named command line handler; e.g., to run the\n`hello` example command:\n\n```shell\n$PHARO_VM $PHARO_IMAGE clap hello\n$PHARO_VM $PHARO_IMAGE clap hello --shout you\n```\n\nCommands can also be tested from within the image; running them from an\ninteractive session will not quit the image, but any output from the command\nwill still go to the standard output:\n\n```smalltalk\nClapCommandLineExamples hello\n\tactivateWith: #('hello' '--help').\n```\n\n[travis]: https://travis-ci.org/cdlm/clap-st\n[travis-status]: https://travis-ci.org/cdlm/clap-st.svg?branch=master\n[coveralls]: https://coveralls.io/github/cdlm/clap-st?branch=master\n[coveralls-status]: https://coveralls.io/repos/github/cdlm/clap-st/badge.svg?branch=master\n\n### Contributors\n\nMany thanks to everyone who has contributed to clap in one way or another:\n\nClément Mastin, Damien Pollet, Rajula Vineet Reddy, Christophe Demarey\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpharo-contributions%2Fclap-st","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpharo-contributions%2Fclap-st","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpharo-contributions%2Fclap-st/lists"}