Comments (5)
That change was in my PR, definitely did not intend to break anything. Can you share a command definition that exhibits this problem so we can write a test?
from oakton.
@aidanjryan
In my case it was
[Oakton.Description("WebApi publish endpoint")]
public class ListenCommand : BaseCommand<ListenInput> {
public ListenCommand() {
this.Usage("Listen to commands on default port").Arguments();
this.Usage("Listen to commands").Arguments(i => i.Port);
}
...
and model
public class ListenInput : BaseInput {
[Description("Listening on defined port")]
public int Port { get; set; } = 12345;
[Description("Get binaries"), FlagAlias("withBinaries", 'b')]
public bool WithBinariesFlag { get; set; }
[FlagAlias("restricted", 'r'), Description("Restrict to localhost")]
public bool RestrictedFlag { get; set; }
}
public class BaseInput {
[Description("Consul token"), FlagAlias("token", 't')]
public string ConsulTokenFlag { get; set; }
[Description("Consul HTTP endpoint address"), FlagAlias("http", 'h')]
public string ConsulHttpFlag { get; set; }
[Description("Timeout for waiting rpc response"), FlagAlias("timeout", 'i')]
public int TimeoutFlag { get; set; } = 30;
[Description("Environment name for settings discovery"), FlagAlias("env", 'e')]
public string EnvironmentFlag { get; set; } = "local";
}
with command line listen -e local
But I think it would break any case, with custom usage of 'optional' arguments
from oakton.
@aidanjryan
If there are some questions about my example, I can provide more information.
from oakton.
@kae Sorry I'm just getting around to reproducing this. I see where building input from usages is failing when all arguments are optional. Could you explain what you meant here?
This change missing "configuration" of usages in constructor of command and always validate on "default" usage with all arguments.
from oakton.
@kae Nevermind! I see what you mean - when the usages are built in isolation without the command constructor self-configuring the usages, custom usages aren't present.
This is a catch-22 for the purpose of the "BeforeBuild" hook -- the idea was to allow a DI container to be configured based on the input, before commands are constructed, in case some DI config is required based on the input.
I think what's required is splitting BuildInput's two responsibilities of creating and validating the input. I'll work on a fix now.
from oakton.
Related Issues (20)
- Test Describe command with application bootstrapped through WebApplication HOT 1
- Console application doesn't exit when using RunOaktonCommands for HostBuilder HOT 1
- New "stateful resource" model
- Stateful resources are automatically environment checks
- Discover service registrations from the [OaktonInclude] attribute
- "Activator" for resource setup
- Improved help output
- Wrong help generated for dictionaries
- "describe" command throws exception when configuration values contain "[" HOT 1
- Mandatory arguments HOT 2
- Duplicate short flag alias when 2 argument properties start with the same alphabet HOT 1
- Cannot set environment because IHost is already constructed in .NET 6 web app HOT 2
- Issue when using Custom Command Creator Pattern HOT 1
- Issue with resources check
- (Web) Application does not exit gracefully when receiving `SIGTERM`
- Provide the capability to allow stateful resources to have dependencies HOT 1
- Support IHealthCheck as part of environment checks
- Make the display for check-env better for failures
- Add ability to not swallow exceptions
- Support Keyed services 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 oakton.