Comments (7)
If a developer has written [HandleCommand("foo", Description="Do the bar thing")]
and then needs to make the description localisable, how would they change the code?
from command-line-api.
We're currently using CommandLineParser in most of our Projects. They solve it as follows:
Adding the HelpText will use the Text supplied. If ResourceType is set, than it will be used as the HelpText Resource Provider:
[HandleCommand("foo", Description=nameof(Resources.SR_FooCommandDescription), DescriptionResource=typeof(Resources))]
I would also prefer using System.Component.DescriptionAttribute, but as far as I am concerned, it is not localizable either, is it?
What do you think?
from command-line-api.
Most equivalent work is also present in System.ComponentModel
and System.ComponentModel.DataAnnotations
. It would be good to support it this way.
from command-line-api.
Please note, that I am also willing to contribute the implementation for this, but I won't create an implementation and add much effort into it, if the PR will be close because this is not wanted or even added to the scope by the maintainers.
from command-line-api.
DescriptionAttribute itself is not localizable, but derived classes can load the description from resources, like here: https://github.com/dotnet/runtime/blob/bf5e279d9239bfef5bb1b8d6212f1b971c434606/src/libraries/System.ComponentModel.TypeConverter/src/System/Timers/TimersDescriptionAttribute.cs#L24
I suppose a source generator could support that by translating [CustomDescription("ResourceKey")]
to new CustomDescriptionAttribute("ResourceKey").Description
if it detects that CustomDescriptionAttribute is based on DescriptionAttribute.
from command-line-api.
Just as an FYI, there is already a 3rd-party project that is trying to do what you seek: #2310 (based on the System.CommandLine version available on the public nuget.org and not on the newer System.CommandLine code base as present in the repository here, as it seems). It supports code generation but it seems to lack localization features as of now.
from command-line-api.
Awesome!
from command-line-api.
Related Issues (20)
- Replace `ParseError`/string errors with `Error` and use generally HOT 7
- Create error reporting output HOT 1
- [Proposal] Validation
- Some naming and organizational issues
- [Proposal] Diagramming
- [Proposal] Remove `TreatUnmatchedTokensAsErrors` HOT 7
- HostingAction for options handlers HOT 3
- HostingAction wrapper does not honor Terminating flag of original action
- [Proposal] Remove global options in Powderhouse parser HOT 3
- [Proposal] Unifying public parts of ArgumentResult and OptionResult to ValueResult and isolating parser support HOT 2
- [Proposal] ValueSubsystem - default values HOT 1
- BinderBase functionality replacement HOT 1
- Required command was not provided on `RootCommand` HOT 6
- [Proposal] Values API HOT 1
- EnvironmentDirective has a hard-coded call to Environment.SetEnvironmentVariable making it hard to test
- Breaking changes for Powderhouse
- Usage root command does not display `ToolCommandName` HOT 1
- [Breaking] Remove CommandResult HOT 6
- Powderhouse support for .NET versions
- Tracking issue for Error changes
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 command-line-api.