Comments (6)
Hi Jörg,
Congratulations! You have found a good bug!
I'll fix it ASAP and release a new version.
Unfortunately there isn't an option to write your own type converter.
Until this is resolved, you can define a const that will treated as a null value. This is a bad practice (and ugly as hell), but it will help you until I release the new version.
For example:
const int SomeConstAsNull = -999;
[Verb]
void Foo([Parameter(Default=SomeConstAsNull)] int x)
{
int? xx = x == SomeConstAsNull ? null : x;
// continue using xx instead of x ...
}
Thanks,
Adrian
from clap.
OK. It's fixed now.
Please update your CLAP nuget (run "Update-Package clap" from your nuget console).
With this version, all the following are supported:
[Verb]
void Foo(
int? p1,
[Parameter(Default=5)] int? p2,
[Parameter(Default="5")] int? p3,
[Parameter(Default="")] int? p4,
[Parameter(Default=null)] int? p5)
{
}
Hope it solves your problem.
Thanks,
Adrian
from clap.
And by-the-way, also custom types with nullable properties are supported:
class Data
{
public int? Number { get;set; }
}
class Program
{
[Verb]
void Foo(Data d)
{
}
}
and running as:
theexe foo id:{Number:5}
from clap.
Adrian,
now how awesome is that.. fixed so quickly, great! I'll give it a try tomorrow morning but thanks :)
Have a nice evening and all the best,
-J
from clap.
Cheers!
from clap.
Confirmed, works!
from clap.
Related Issues (20)
- Multiple apps and help - how to call? HOT 4
- Merge #24 break when an exception is not serializable HOT 2
- Allow sequence of Verbs HOT 2
- Allow [DirectoryExists], [FileExists], [PathExists] to be applied to global parameters HOT 3
- Help text of parameters not displayed HOT 3
- Error attribute is ignored when RunConsole is used HOT 2
- .pdb file is included in nuget package HOT 4
- Required property on ParameterAttribute not working HOT 1
- Remove Windows.Forms Dependency HOT 3
- Strong name assemblies HOT 3
- Help isn't being shown HOT 2
- Correctly bubbling exit-codes HOT 2
- couldn't make it work HOT 2
- Add support for Argument Models HOT 3
- Feature Request: Interactive REPL shell support HOT 1
- Simpler scenarios support HOT 1
- Create base exception class for all CLAP exceptions HOT 2
- Parameter Help format HOT 1
- [PreVerbExecution] method not called for [Empty] verb
- How can I create such an awesome website? HOT 1
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 clap.