Comments (3)
Currently, all record fields of type option
are converted to cmdliner optional arguments. It currently passes its name as None
which is causing the error in the nested function calls that implement cmdliner's functionality at runtime. since optional arguments must be named. If the type of the record field is option
, any other attributes not related to optional arguments (including [@pos *]
) are ignored, which is not what should have happened here, of course.
I am guessing you would like something more like what Rust's structopt does with positional arguments whose underlying type is Option<T>
. The issue is that I don't think this functionality is possible given cmdliners's CLI semantics. We should instead have raised an error when the PPX code generation was running explaining that positional arguments cannot be type option, which is something that we can fix pretty easily, although it may not be what you were hoping for.
What cmdliner does support, however, is the notion of a positional argument that consumes an arbitrary number of tokens (e.g., look at the files
argument in the cmdliner rm
example). We could conceivably add new attributes like [@pos_all]
and [@pos_right *]
to go with cmdliner's pos_all
and pos_right
which would take an arbitrary number of positional arguments and put them into a list. I realize that it is not an exact match to the functionality you wanted, but as far as I can tell, cmdliner does not support any optional positional arguments otherwise. The use of subterms for multiple/optional arguments is something cmdliner's docs explicitly warn against as likely to break in the future. We can keep this issue open to track this new feature, if you would like.
from ppx_deriving_cmdliner.
The issue is that I don't think this functionality is possible given cmdliners's CLI semantics.
I guess I'm confused by their docs then, because it says this for pos
: "If the positional argument is absent from the command line the argument is v
." Which makes it seem like I could specify v
as None to make it an optional value?
from ppx_deriving_cmdliner.
In any case, even having pos_all
and pos_right
would be helpful, as I can't support an optional positional argument at all right now.
from ppx_deriving_cmdliner.
Related Issues (20)
- Support [@cmdliner.term …] to specify custom Term.t
- Support [@cmdliner.conv …] to support custom converter HOT 1
- "include" for terms
- `[@enum ...]` ignored without error message or warning
- Create "the main entry point" `[@@cmdliner.eval params]`
- Add ocaml 4.04.0 to the Travis build-matrix
- Better support enums for tuples HOT 1
- Support variants
- Strip doc strings to preserve alignment HOT 2
- jbuilder/dune support? HOT 1
- Default parameters HOT 1
- Scope of generated `[@ocaml.warning "-A"]` too narrow HOT 1
- I don't see a way to do pos_all -- but think I know how to extend HOT 1
- Deprecation of cmdliners converter type HOT 5
- ocaml 4.10.0 support HOT 1
- New release with Dune 2.0 support? HOT 1
- Release 0.5.0 has "0.4.2-dev" in the version field of the .opam file
- Port to the latest version of ppx_deriving HOT 2
- 0.6.0 does not compile 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 ppx_deriving_cmdliner.