All Projects → pharo-contributions → clap-st

pharo-contributions / clap-st

Licence: other
Command-line argument parsing for Pharo

Programming Languages

smalltalk
420 projects

Projects that are alternatives of or similar to clap-st

Grease
The Grease Portability Library
Stars: ✭ 12 (-55.56%)
Mutual labels:  pharo
themes
A repository for alternative Pharo themes
Stars: ✭ 18 (-33.33%)
Mutual labels:  pharo
cmdr
POSIX-compliant command-line UI (CLI) parser and Hierarchical-configuration operations
Stars: ✭ 94 (+248.15%)
Mutual labels:  command-line-parser
Buoy
A complement to Pharo
Stars: ✭ 18 (-33.33%)
Mutual labels:  pharo
libtensorflow-pharo-bindings
TensorFlow library bindings for Pharo
Stars: ✭ 30 (+11.11%)
Mutual labels:  pharo
NeoJSON
NeoJSON is an elegant and efficient standalone Smalltalk framework to read and write JSON converting to or from Smalltalk objects.
Stars: ✭ 29 (+7.41%)
Mutual labels:  pharo
Microdown
Microdown is a cleaned and simpler markdown but with more powerful features such as extensions.
Stars: ✭ 26 (-3.7%)
Mutual labels:  pharo
pharo-talents
No description or website provided.
Stars: ✭ 20 (-25.93%)
Mutual labels:  pharo
RenoirSt
A DSL enabling programmatic cascading style sheet generation for Pharo Smalltalk
Stars: ✭ 19 (-29.63%)
Mutual labels:  pharo
mars-gtk
The Gtk3 bindings for Pharo and Spec
Stars: ✭ 14 (-48.15%)
Mutual labels:  pharo
fari.sh
fari.sh — fresh, ready-to-hack Pharo images
Stars: ✭ 12 (-55.56%)
Mutual labels:  pharo
Utility.CommandLine.Arguments
A C# .NET class library containing tools for parsing the command line arguments of console applications.
Stars: ✭ 105 (+288.89%)
Mutual labels:  command-line-parser
QualityAssistant
A live feedback code quality tool for Pharo
Stars: ✭ 17 (-37.04%)
Mutual labels:  pharo
CommandLineParser.Core
💻 A simple, light-weight and strongly typed Command Line Parser made in .NET Standard!
Stars: ✭ 32 (+18.52%)
Mutual labels:  command-line-parser
opensmalltalk-vm
This is the VM used by Pharo
Stars: ✭ 59 (+118.52%)
Mutual labels:  pharo
NeoCSV
NeoCSV is an elegant and efficient standalone Smalltalk framework to read and write CSV converting to or from Smalltalk objects.
Stars: ✭ 20 (-25.93%)
Mutual labels:  pharo
structopt-toml
An default value loader from TOML for structopt
Stars: ✭ 23 (-14.81%)
Mutual labels:  command-line-parser
pharo-server-tools
Tools to deploy and manage headless Pharo servers from the command line
Stars: ✭ 25 (-7.41%)
Mutual labels:  pharo
toml-sort
Toml sorting library
Stars: ✭ 31 (+14.81%)
Mutual labels:  command-line-parser
minimist2
TypeScript/JavaScript ES6 rewrite of popular Minimist argument parser
Stars: ✭ 20 (-25.93%)
Mutual labels:  command-line-parser

clap — Command line argument parser for Pharo

Build Status Coverage Status

Named after and inspired by clap-rs, but this is an independent implementation.

Terminal screencast demo

Currently still in the initial implementation phase, meaning the main pieces are there but many features are still missing and may force changes in the design.

Loading instructions

starting from a Pharo image

Metacello new baseline: 'Clap';
    repository: 'github://cdlm/clap-st/src';
    load.

starting from the shell

git clone https://github.com/cdlm/clap-st.git
cd clap-st
curl get.pharo.org/alpha+vm | bash

…and then, in the image just downloaded, open a workspace and evaluate:

Metacello new baseline: 'Clap';
   repository: 'gitlocal://./src';
   load.

Shameless plug: I work with Fari and direnv to automate building and launching the development image:

# setup $PHARO
fari build
fari run

Defining and invoking commands

Commands and subcommands are instances of ClapCommand. To make a command accessible from the command line, return it from a class-side factory method with the <commandline> pragma. For instance, here's how we declare the traditional hello, world! example, with the actual behavior delegated the instance-side method ClapCommandLineExamples >> sayHello:

hello
	"The usual Hello-World example, demonstrating a Clap command with a couple options."
	<commandline>

	^ (ClapCommand withName: 'hello')
		description: 'Provides greetings';
		add: ClapFlag forHelp;
		add: ((ClapFlag withName: 'shout')
			description: 'Greet loudly');
		add: ((ClapPositional withName: 'who')
			description: 'Recipient of the greetings';
			defaultMeaning: [ 'world' ]);
		meaning: [ :args |
			args atName: 'help' ifFound: [ :help |
				help value.
				help context exitSuccess ].

			(self with: args) sayHello ]

For now, Clap installs itself as a named command line handler; e.g., to run the hello example command:

$PHARO_VM $PHARO_IMAGE clap hello
$PHARO_VM $PHARO_IMAGE clap hello --shout you

Commands can also be tested from within the image; running them from an interactive session will not quit the image, but any output from the command will still go to the standard output:

ClapCommandLineExamples hello
	runWith: #('hello' '--help').

Contributors

Many thanks to everyone who has contributed to clap in one way or another:

Clément Mastin, Damien Pollet, Rajula Vineet Reddy

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].