Comments (1)
Hey @gusutabopb, thank you for the good suggestion, in fact this was one of the major missing features.
Your proposal is quite neat, the only issue I have with it is that the existence of a cli
kwarg is of course not explicitly stated since it's not native to pydantic, as well as the use of a dictionary it' not very "declarative", meaning that it's hard to know what to provide as input (thinking about IDE suggestions like IntelliSense).
At the same time this modification has a very low impact, which is nice.
A solution I was instead considering consisted in creating a custom CLIField
inheriting Field
, to provide this functionality this way (which requires a bit more work than yours, but probably not that much):
class Config(BaseModel):
name: str = CLIField("-n", "--old-name", default="Mark", description="Your name", other_custom_cli_stuff="value")
count: int = CLIField("-c")
Basically it would prioritize the functionality the CLI needs without interfering with pydantic. The main logic of CLIField would remain in the init
, handling its custom fields and forwarding to super
for the rest, in the right order.
Let me know what you think about this.
And thanks to you for giving this thing a try!
from clidantic.
Related Issues (14)
- Implement proper tests
- Add the remaining click arguments
- Add documentation
- Implement proper versioning
- Clidantic gets extra argument when only one command is set HOT 1
- Literal type not supported
- Add different operative systems
- Add unit tests on types
- Investigate dynamic model creation for multiple input args in commands
- Custom length for help texts HOT 1
- Missing description in commands
- Type of basemodel is evaluated as 'str' when using `from __future__ import annotations` HOT 2
- Forward references are not supported
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 clidantic.