Giter Club home page Giter Club logo

Comments (10)

genotrance avatar genotrance commented on May 24, 2024

I believe this is now implemented with -dD. We need to add tests though.

from nimterop.

c-blake avatar c-blake commented on May 24, 2024

This seems as appropriate an issue thread as any to chime in, but I saw that I think you (shashlick?) in IRC a few days ago asked about cligen handling -I multiple times or probably similarly for -D. No one seemed to answer you, and I suppose there's a chance you tried it and saw that it "just worked", but its CL usage is a little subtle.

An explicit = or : or long option param separation causes things to "reset" to the argument. So, --defines=def0,def9 will clobber any existing seq with just ["def0", "def9"]. A short option (if you added short={ "defines": 'D', "includeDirs", 'I' } ) would let the CLI user say -Ddef1 -Ddef2 with the intended accumulating meaning. They can also use an explicit append mode via --defines+=def3 and even a prepend mode -I^=earlierpath. I found it a little tricky balancing the "need to reset" with the principle of least surprise, and this is only really in the documentation for argcvt. I could be convinced that maybe "reset and assign" should be spelled .= or something. There's been talk of the need for a --help-syntax or something more to guide CL users.

If you hate this syntax, you can also override all of this default syntax by just by doing an import cligen, cligen/argcvt and, between that import and the dispatch. defining your own version of proc argParse*[T](dst: var seq[T], ... . It's only a 19 line proc in cligen/argcvt.nim, but you might also need to learn some more internals to do it.

from nimterop.

genotrance avatar genotrance commented on May 24, 2024

@c-blake - thanks for chiming in. I wasn't able to since the += and ^= syntax isn't obvious and there weren't any examples either. I also just tried to see the argcvt docs and it doesn't seem to work. Says table not accessible.

That being said, @timotheecour has already migrated nimterop to use cligen. Here's the syntax so far:

Usage:
  main [required&optional-params]
  Options(opt-arg sep :|=|spc):
  -h, --help                                  write this help to stdout
  -m=, --mode=         string       "cpp"     language; see CompileMode
  -p, --past           bool         false     print AST output
  --pnim               bool         false     run preprocessor on header
  --pretty             bool         true      set pretty
  --preprocess         bool         false     print Nim output
  -d=, --defines=      ,SV[string]  EMPTY     definitions to pass to preprocessor
  -i=, --includeDirs=  ,SV[string]  EMPTY     include directory to pass to preprocessor
  -s=, --source=       string       REQUIRED  C/C++ source/header

from nimterop.

c-blake avatar c-blake commented on May 24, 2024

Not sure what's wrong with the http://htmlpreview.github.io/?, but I also get that error a day later. That file is just the output of nim doc argcvt.nim. So, you can also just read the doc comments there.

Also, I don't think I was so clear...Had you tried just "-i dir1 -i dir2" (with no "=") then it would have appended rather than doing a clobbering assignment. It only does the clobbering assignment with an explicit '=' (at least right now). So, it seemed possible to me you might have discovered that subtle property by accident. I don't think of += as very likely to be tried. But, yeah, there should be example usage/--help-syntax. parsopt3 is also quite a bit more flexible than the stdlib parseopts.

from nimterop.

timotheecour avatar timotheecour commented on May 24, 2024

Not sure what's wrong with the http://htmlpreview.github.io/?, but I also get that error a day later.

not sure what you meant above but http://htmlpreview.github.io/?https://github.com/c-blake/cligen/blob/master/argcvt.html worked for me (link given at end of README in https://github.com/c-blake/cligen ; admittedly I'd prefer if that link appeared on top of README)

--help-syntax

=> moved that discussion to c-blake/cligen#64

from nimterop.

timotheecour avatar timotheecour commented on May 24, 2024

@genotrance

I believe this is now implemented with -dD. We need to add tests though.

is it, though? that's why I was trying to test with #17 but it fails

from nimterop.

genotrance avatar genotrance commented on May 24, 2024

#17 was last tested 5 days ago but preprocessor was only enabled 4 days ago. Maybe if we close and reopen it, it might pass.

7344042

from nimterop.

timotheecour avatar timotheecour commented on May 24, 2024

indeed, travis now passes! appveyor still fails though

EDIT: hmm, appveyor fails on ubuntu...

/home/appveyor/projects/nimterop/tests/tnimterop_c.nim(21, 15): Check failed: myvar1 == 20
myvar1 was 10
Error: execution of an external program failed: '/home/appveyor/projects/nimterop/tests/tnimterop_c '
stack trace: (most recent call last)
/home/appveyor/projects/nimterop/nimterop.nimble(20) testTask
/home/appveyor/projects/nimterop/nimterop.nimble(17) execCmd
/home/appveyor/binaries/nim-0.19.0/lib/system/nimscript.nim(237) exec
/home/appveyor/binaries/nim-0.19.0/lib/system/nimscript.nim(237, 7) Error: unhandled exception: FAILED: nim c -r tests/tnimterop_c.nim

from nimterop.

genotrance avatar genotrance commented on May 24, 2024

This has been fixed.

from nimterop.

timotheecour avatar timotheecour commented on May 24, 2024

@genotrance could we reopen?
constants works but not C macros, see #30

EDIT: moved to #31

from nimterop.

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.