Comments (10)
I believe this is now implemented with -dD. We need to add tests though.
from nimterop.
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.
@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.
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 parseopt
s.
from nimterop.
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.
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.
#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.
from nimterop.
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.
This has been fixed.
from nimterop.
@genotrance could we reopen?
constants
works but not C macros
, see #30
EDIT: moved to #31
from nimterop.
Related Issues (20)
- Parsing a global variable that's a pointer to an array of functions
- Structs mapped from C header need completeStruct pragma, otherwise sizeof doesn't work on those
- VM does not support 'cast' from tyFloat to tyFloat HOT 2
- [Question] Change build directory HOT 1
- Toast parsing comment as var HOT 4
- Inject code to process `#define`? HOT 8
- Building Failed with nimble. HOT 2
- [Question] Binding to OpenCV HOT 2
- Using nimterop in MSYS2 Bash environment on Windows HOT 3
- Header path handling on Windows HOT 3
- βuint16_t β What happened?
- Typedef function with an enum return type
- Support OpenBSD
- The nimterop good this reference documentation to convert small C project
- [Question] Nimterop, libnx and DevKitPro | sys/lock.h : No such file or directory HOT 1
- "cmd: not found" when building using mingw building a windows executable in linux
- ssing comma in the example
- Toast segfault with comment after define
- Build fails due to `macro getHeader` Implementation
- Documentation
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 nimterop.