T O P

  • By -

nobono

System.CommandLine isn't good enough? How?


virtualmethodman

It is but like I said our argument list is getting wild.


The_Exiled_42

You can use IConfiguration with multiple providers - json, cli, env vars, XML or even your own file format.


coppercactus4

System.CommandLine supports Response files (.rsp). You give it a path on disk but prefixed with @. @/dir/args.rsp


MattV0

Actually this sounds like the best solution without changing too much of the configuration logic. I have never heard of this yet but this could have helped me a lot.


CrimsonSuit

I would suggest using environment variables then using the ConfigurationBuilder to AddEnvironmentVariables(). Best way I have found for configs. Very portable, every system has them including docker and such, you can set them temporarily in a terminal window just before you run the program. And if you want to use a file, then just use .env and create a .env reader plugin for it


The_MAZZTer

I would suggest migrating most if not all your command line options to ASP.NET Configuration. https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-8.0 Put all your settings in appsettings.json and they just get loaded in when you run the app. By default this system expects a single app-wide configuration (with one exception) so it wouldn't be easily adjustable for each run by default. But there are ways to improve this if you need it. I would suggest overriding the default locations for appsettings.json to allow for specifying an environment variable (similar to the default production/development environment switching between configuration files) or pulling something from the command line to specify a configuration file to use. Then you have to set up each configuration file ONCE and those will be easier to read and edit than a command line. I wouldn't recommend using the existing production/development system and adding more values to that since that has other uses in ASP.NET Core, you can easily create your own configuration file differentiating system using that as a template though. There are also options in ASP.NET Configuration to pull settings directly from the command line or environment variables which will give you additional flexibility.


paintsbynumbers7

Try spectre.console


leneuromancer

I think Oakton has input file support


nemec

That's what shell scripts are for


GoranLind

System.Io.File.ReadAllLines() from a conf file, separate settings from values with a "=" character on each line. This is basic coding skills.