Comments (3)
For reference, I worked around this by handling the top level commands myself, then building a CommandExecutor
for the specified command: Gist
@jeremydmiller BTW, I really like how simple yet well-featured this library is compared to the bigger ones!
from oakton.
You can use arguments to effect sub commands. Your Oakton command can vary on what it actually does by just doing a switch in the Execute on the argument. Oakton was originally built in the FubuCore days -- for better or worse -- as a way to build tools like the git cli
from oakton.
Do you mean using something like this:
[Description("Work with volumes", Name = "volume")]
public class VolumeCommand : OaktonAsyncCommand<VolumeInput>
{
private readonly AppConfig appConfig;
public VolumeCommand(AppConfig appConfig)
{
this.appConfig = appConfig;
Usage("Work with a volume").Arguments(x => x.Action, x => x.Name);
}
public override async Task<bool> Execute(VolumeInput input)
{
// Switch on input.Action here
}
}
public class VolumeInput
{
public CommandAction Action { get; set; } = VolumeAction.ls;
public string Name { get; set; };
public enum CommandAction
{
create,
ls,
inspect,
rm,
}
}
Let's say I also wanted a command my-app volume ls
, i.e. the ls action, but without any arguments - any idea how I could achieve this while still keeping the CommandUsage
from the above code working?
from oakton.
Related Issues (20)
- Usage of opts file HOT 2
- Usage breaks logging HOT 6
- .NET 6? HOT 3
- New recipe for using Oakton with WebApplication HOT 1
- Move the documentation to Vitepress/MarkdownSnippets
- 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`
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.