Comments (10)
(Embarassed cat face). Because it seems that -h is hardwired to mean 'help'! Easy for me to fix however; if a person defines '-h' (or '--help') then don't use the default handling.
from penlight.
LoL, ok it was an end of the day bug (tiredness doesn't help debugging).. And, in an older program of mine, I was already using such -h
for the --height
contraction and therefore I couldn't understand why it wasn't working and no error or warning was thrown up.
Tnx for the prompt feedback!
One further question: would it make sense to use multi-characters contractions? For example -s
for --save
and -sk
for -seek
? This is because I've plenty of scripts that uses multi-characters shorteners and I'd like to keep some kind of back compatibility even if I'm cleaning up the code.
from penlight.
The problem with -sk
is that a common interpretation is that this is short for -s -k
. We can have an option to disable this behaviour for a particular flag (or all flags) but then people might be confused?
from penlight.
No, you're right, but if I'm writing
-sk,--seek (number) Seconds to seek
then there wouldn't be any confusion, right? As long as I define it myself I wouldn't get confused. But maybe I'm asking you too much..
from penlight.
I'm more worried about users getting confused. But then, there are many standards for command line args (some use single hyphen for long flags as well). So I should not be too fascist and impose GNU-style on all my users. Let me have a look at what's involved...
from penlight.
He, he, he, you're fun to speak with! Now it's 04:30 and I'm laughing instead of sleeping. LoL But I guess if you state clearly you care about GNU compatibly, then who's going to use your tools will automatically accept the thing. So, don't waste your time listening to me and having the -h
not forced to --help
is more than enough!!
from penlight.
Ah, it turned out to be easy - but you do have to use 'slack' mode ;)
-- alfredo.lua
require 'pl'
lapp.slack = true
args = lapp [[
Does some calculations
-vs,--video-set (string) Use the German road sign dataset
-w,--width (default 256) Width of the video
-h,--height (default 144) Height of the video
-t,--time (default 10) Seconds of video to process
-sk,--seek (default 0) Seek number of seconds
-dbg Debug!
]]
pretty.dump(args)
Call like so:
D:\dev\lua\Penlight\scratch>lua alfredo.lua -vs 200 -sk 1
{
video_set = "200",
time = 10,
height = 144,
seek = 1,
dbg = false,
width = 256
}
from penlight.
Great! Thank you @stevedonovan! Everything's fine but the pretty.dump(args)
. Lua tells me pretty
is undefined (a nil value).
from penlight.
That's strange! With the example as typed (using require 'pl'
to make the submodules all available) it shows no such error. What system are you using?
from penlight.
Ok, I mess up again, and I was using your local
configuration (local lapp = require 'pl.lapp'
)...
Anyhow, I am using Torch and.. for printing tables I just use print(args)
.
So, this code
-- Plotting the parsed commands ------------------------------------------------
print 'args ='
print(args)
pretty = require 'pl.pretty'
pretty.dump(args)
gives me
that is quite nicer
from penlight.
Related Issues (20)
- array2d indexing - allow str input to automatically parse range HOT 2
- deprecating the `pl.text` module HOT 7
- Busted tests fail if lua interpreter specified HOT 1
- warn compatibility function causes write guard warning in OpenResty HOT 2
- Cleanup: move pl.path, pl.file and pl.dir into a single module HOT 5
- Cleanup: move pl.lapp and pl.config into pl.app HOT 2
- Cleanup: move pl.stringio into the pl.stringx module
- Cleanup: deprecate pl.test HOT 1
- Cleanup: drop or improve pl.url HOT 4
- Consider adding the built-in table methods to tablex? HOT 3
- Clone a function? HOT 8
- How about adding json decode and encode function HOT 4
- Error in pretty.write: invalid order function for sorting
- Bareword `warn` in compat.lua is a "strict" violation
- pl.Path.isdir Doesn't work correctly for Windows Base directory i.e. D:\\ (Lua 5.4.4) HOT 1
- Test suite failing on Arch Linux HOT 2
- lfs HOT 1
- stringx indent and dedent functions add an extra "\n" at the end of the string HOT 3
- lexer.cpp doesn't recognize #define without trailing newline HOT 2
- Can't use % as escape character in a template HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from penlight.