Coder Social home page Coder Social logo

Lapp and bug about penlight HOT 10 CLOSED

lunarmodules avatar lunarmodules commented on July 22, 2024
Lapp and bug

from penlight.

Comments (10)

stevedonovan avatar stevedonovan commented on July 22, 2024

(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.

Atcold avatar Atcold commented on July 22, 2024

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.

stevedonovan avatar stevedonovan commented on July 22, 2024

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.

Atcold avatar Atcold commented on July 22, 2024

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.

stevedonovan avatar stevedonovan commented on July 22, 2024

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.

Atcold avatar Atcold commented on July 22, 2024

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.

stevedonovan avatar stevedonovan commented on July 22, 2024

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.

Atcold avatar Atcold commented on July 22, 2024

Great! Thank you @stevedonovan! Everything's fine but the pretty.dump(args). Lua tells me pretty is undefined (a nil value).

from penlight.

stevedonovan avatar stevedonovan commented on July 22, 2024

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.

Atcold avatar Atcold commented on July 22, 2024

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

screen shot 2013-06-27 at 13 19 53

that is quite nicer 😉

from penlight.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.