ianthehenry / cmd Goto Github PK
View Code? Open in Web Editor NEWcommand-line argument parser for Janet
License: MIT License
command-line argument parser for Janet
License: MIT License
It seems like the focus of cmd
at present is on shebang-style Janet scripts. But I'm trying to build native executables with jpm
. I haven't been able to get even a "Hello, World" working based on the instructions in the README. Could you please point me in the right direction?
I notice that when a command doesn't have a docstring, its hyphen separator in the formatted help text prints misaligned from the other commands:
It almost looks like this is done on purpose in help.janet
:
Line 102 in 03801e7
If it wasn't for that empty?
check, the hyphen would always align regardless. So that makes this behavior look intentional.
I'm curious why?
For this example program:
(import cmd)
(cmd/main (cmd/fn
[--greeting (optional :string "Hello")
name :string]
(printf "%s, %s!" greeting name)))
When run as a script using janet main.janet
works as expected, but when compiled using jpm quickbin main.janet example
and run we get this error:
error: bad slot #1, expected string, symbol, keyword or buffer, got nil
in string/split [src/core/string.c] on line 445
in is-probably-interpreter? [/opt/homebrew/Cellar/janet/1.30.0/lib/janet/cmd/util.janet] on line 78, column 12
in args [/opt/homebrew/Cellar/janet/1.30.0/lib/janet/cmd/arg-parser.janet] on line 148, column 9
in main [main.janet] on line 6, column 1
...and -h
too, probably.
We should actually probably accumulate flags and only look at positional arguments.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.