Skip to content

Commit

Permalink
chore: Start depending on prantlf.strutil
Browse files Browse the repository at this point in the history
  • Loading branch information
prantlf committed Aug 10, 2023
1 parent 38ac6ba commit ab750df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/parse.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import math
import regex
import strconv
import v.reflection
import prantlf.strutil { replace_u8 }

pub struct Input {
pub mut:
Expand All @@ -21,7 +22,7 @@ pub fn parse[T](usage string, input &Input) !(&T, []string) {
return cfg, cmds
}

pub fn parse_to[T](usage string, input &Input, mut cfg &T) ![]string {
pub fn parse_to[T](usage string, input &Input, mut cfg T) ![]string {
d.log_str('parse command-line usage and fill options')
mut re_opt := regex.regex_opt('^-([^\\-])|(?:-([^ =]+))(?:\\s*=(.+))?$') or { panic(err) }

Expand Down Expand Up @@ -439,7 +440,7 @@ fn get_float[T](val string, ignore_overflow bool) !T {
fn (opt Opt) field_name() string {
name := if opt.long.len > 0 {
if opt.long.contains_u8(`-`) {
opt.long.replace_char(`-`, `_`, 1)
replace_u8(opt.long, `-`, `_`)
} else {
opt.long
}
Expand Down
2 changes: 1 addition & 1 deletion v.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Module {
description: 'Parses command-line arguments to statically typed options or a string map with the help of usage description.'
version: '0.1.0'
license: 'MIT'
dependencies: ['prantlf.debug']
dependencies: ['prantlf.debug', 'prantlf.strutil']
}

0 comments on commit ab750df

Please sign in to comment.