Skip to content

Commit

Permalink
Fixed ability to add Names and Descriptions for Commands converted fr…
Browse files Browse the repository at this point in the history
…om Functions

- Changed `Command.fromFn()` to use the `FromConfig.sub_descriptions` directly instead of converting it to a `StaticStringMap`.
- Updated README commit activity badge.
  • Loading branch information
00JCIV00 committed Sep 29, 2024
1 parent 26a3c0e commit f915352
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A simple yet robust cross-platform command line argument parsing library for Zig

[![Static Badge](https://img.shields.io/badge/v0.13(stable)-orange?logo=Zig&logoColor=Orange&label=Zig&labelColor=Orange)](https://ziglang.org/download/)
[![Static Badge](https://img.shields.io/badge/v0.10.1b-blue?logo=GitHub&label=Release)](https://github.com/00JCIV00/cova/releases/tag/v0.10.1-beta)
[![GitHub commit activity](https://img.shields.io/github/commits-since/00JCIV00/cova/latest/v0.10.1?include_prereleases&logo=Github&label=Commits%20(v0.10.1b))](https://github.com/00JCIV00/cova/commits/v0.10.1/)
[![GitHub commit activity](https://img.shields.io/github/commits-difference/00JCIV00/cova?base=v0.10.1&head=main&logo=Github&label=Commits%20(v0.11.0b))](https://github.com/00JCIV00/cova/commits/main/)
[![Static Badge](https://img.shields.io/badge/MIT-silver?label=License)](https://github.com/00JCIV00/cova/blob/main/LICENSE)

___
Expand Down
6 changes: 3 additions & 3 deletions src/Command.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1203,13 +1203,13 @@ pub fn Custom(comptime config: Config) type {
const from_vals = from_vals_buf[0..];
var vals_idx: u8 = 0;

const arg_descriptions = StaticStringMap([]const u8).initComptime(from_config.sub_descriptions);
const arg_details = from_config.sub_descriptions; //StaticStringMap([]const u8).initComptime(from_config.sub_descriptions);

const params = from_info.Fn.params;
const start_idx = if (from_config.ignore_first) 1 else 0;
inline for (params[start_idx..], 0..) |param, idx| {
const arg_name: ?[]const u8 = if (idx < arg_descriptions.keys().len) arg_descriptions.keys()[idx] else null;
const arg_description = if (idx < arg_descriptions.values().len) arg_descriptions.values()[idx] else "";
const arg_name: ?[]const u8 = if (idx < arg_details.len) arg_details[idx][0] else null;
const arg_description = if (idx < arg_details.len) arg_details[idx][1] else "";
//const arg_description = "No description. (Descriptions cannot currently be generated from Function Parameters.)";//arg_descriptions.get(param.name);
// Handle Argument Types.
switch (@typeInfo(param.type.?)) {
Expand Down

0 comments on commit f915352

Please sign in to comment.