Comments (4)
Initial design:
Extend CommandOptionAttribute
/CommandParameterAttribute
with an additional property Type? ConverterType { get; set; }
. The converter has to implement some IArgumentConverter
.
Since an argument can be scalar and non-scalar, in order to support both, IArgumentConverter
would need to either have two methods (for a list of arguments and for one argument) or have one just for a list and let the user deal with it (nasty). It also needs a property IsScalar
which is important when binding parameters from multiple arguments because it needs to be known pretty early.
This overall sounds pretty meh because it exposes quite a few points of failure where the user may forget something or do something incorrectly.
from clifx.
Current workaround without implementing anything:
Assume we have type MyType
and a function MyType Convert(string)
. We can simply define our option/parameter as a string
or IEnumerable<string>
and then do the conversion inside ExecuteAsync
manually. Not too pretty but still reasonable.
from clifx.
Hey, @Tyrrrz ! I would like to have a look at this issue. I maybe have a solution which works with both MyCustomType
and IEnumerable<MyCustomType>
and other generic collections, but I am not sure that I clearly catched what did you mean at It also needs a property IsScalar which is important when binding parameters from multiple arguments because it needs to be known pretty early.
As I see, non-scalar types use same scalar type converters for each argument in the list, aren`t they?
from clifx.
Hi @AlexandrShustov.
As I see, non-scalar types use same scalar type converters for each argument in the list, aren`t they?
They do. I think when I wrote this I was thinking of cases where the user may want to convert the entire list, not just item by item. You can ignore this for now and see maybe it's not necessary after all.
from clifx.
Related Issues (20)
- Add IConsole.Clear()
- Separation of model from business logic HOT 7
- Check `BindingConverter<T>` and `BindingValidator<T>` types in analyzers
- Executable name does not appear in help text in some terminals HOT 4
- How do you wrap help output? HOT 1
- Add multi-language output message support HOT 5
- Command examples HOT 3
- Drop support for targets below net5.0 HOT 11
- Positional arguments listed out-of-order when inheriting from base command class HOT 2
- ConsoleWriter is not thread-safe HOT 1
- `IConsole.ReadKey` should return the key that was read HOT 1
- Support `=` (equal sign) as value separator in argument syntax HOT 4
- Assembly binding confusion results in many AD0001 analyzer warnings HOT 11
- `FakeInMemoryConsole.Clear()` has no effect HOT 4
- Capturing Trace and Debug output HOT 1
- Default `IsRequired` for options based on whether the `required` modifier is used on the property
- CliFx.Analyzers produces hundreds of CS8032 warnings in build HOT 9
- Publishing an exe as "PublishSingleFile=true" with version 2.3.4 fails HOT 2
- Calling commands from other rcommands HOT 3
- Allow the non scalar parameter to be optional or have default value HOT 4
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 clifx.