{"repo":"yuhr/fncmd","free":true,"listed":false,"github":"https://github.com/yuhr/fncmd","clone":"git clone https://github.com/yuhr/fncmd.git","description":"Command line interface as a function.","language":"Rust","stars":77,"topics":["rust","cli","macro"],"license":"MPL-2.0","category":"cli-tools","readme_excerpt":"Command line interface as a function. fncmd fncmd is an opinionated command line parser frontend that wraps around clap . The functionality is mostly identical to clap , but provides much more automated and integrated experience. Motivation Imagine a command line program you want to create. Essentially, it can be abstracted as a simple function that takes command line options as arguments. Then there should be nothing to stop you from being able to write it literally as a function, without using structs or builders like today's Rustaceans do. This concept is tremendously inspired by argopt , I really appreciate the work. However, it still requires a bit of cumbersome code, especially for handling subcommands. fncmd has been rewritten from scratch to get rid of all the complexities. Dig into Subcommands section to see how we can handle it. Installation To install, run in your project directory: For those who prefer case studies: see examples . Basics This crate exposes just a single attribute macro, [ fncmd ], which can only be attached to the main function: That's all, and now you got a command line program with options handled by clap . With above code, the help message will be like below: The name and the version of your command are automatically inferred from Cargo metadata. The usage of the opt attribute is almost exactly the same as the underlying arg attribute. They're just passed as is, except that (long) is implied if no configuration was provided, i.e. #[opt] means #","default_branch":null,"files":null,"tree":[],"storefront":"/r/yuhr","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/yuhr/fncmd/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}