diff --git a/Cargo.lock b/Cargo.lock index 486ec4e..7bf1f02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -168,7 +168,7 @@ dependencies = [ [[package]] name = "prefix" -version = "1.2.0" +version = "1.2.1" dependencies = [ "clap", "clap_complete", diff --git a/Cargo.toml b/Cargo.toml index 153f0aa..e4b8799 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "prefix" -version = "1.2.0" +version = "1.2.1" authors = ["Shivix"] edition = "2021" description = "A customizable pretty printer for FIX messages" diff --git a/completion/_prefix b/completion/_prefix index 0a7da05..f676860 100644 --- a/completion/_prefix +++ b/completion/_prefix @@ -30,8 +30,8 @@ _prefix() { '--strict[Only consider full FIX messages containing both BeginString and Checksum]' \ '-s[Strip the whitespace around the = in each field]' \ '--strip[Strip the whitespace around the = in each field]' \ -'-t[Translate tag numbers on non FIX message lines]' \ -'--tag[Translate tag numbers on non FIX message lines]' \ +'-t[Translate tag numbers on non FIX message lines, if the entire line matches a tag name it will print it'\''s number]' \ +'--tag[Translate tag numbers on non FIX message lines, if the entire line matches a tag name it will print it'\''s number]' \ '-v[Translate the values of some tags (for Side\: 1 -> Buy)]' \ '--value[Translate the values of some tags (for Side\: 1 -> Buy)]' \ '-h[Print help]' \ diff --git a/completion/_prefix.ps1 b/completion/_prefix.ps1 index e32a507..c538e9b 100644 --- a/completion/_prefix.ps1 +++ b/completion/_prefix.ps1 @@ -36,8 +36,8 @@ Register-ArgumentCompleter -Native -CommandName 'prefix' -ScriptBlock { [CompletionResult]::new('--strict', 'strict', [CompletionResultType]::ParameterName, 'Only consider full FIX messages containing both BeginString and Checksum') [CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Strip the whitespace around the = in each field') [CompletionResult]::new('--strip', 'strip', [CompletionResultType]::ParameterName, 'Strip the whitespace around the = in each field') - [CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'Translate tag numbers on non FIX message lines') - [CompletionResult]::new('--tag', 'tag', [CompletionResultType]::ParameterName, 'Translate tag numbers on non FIX message lines') + [CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'Translate tag numbers on non FIX message lines, if the entire line matches a tag name it will print it''s number') + [CompletionResult]::new('--tag', 'tag', [CompletionResultType]::ParameterName, 'Translate tag numbers on non FIX message lines, if the entire line matches a tag name it will print it''s number') [CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'Translate the values of some tags (for Side: 1 -> Buy)') [CompletionResult]::new('--value', 'value', [CompletionResultType]::ParameterName, 'Translate the values of some tags (for Side: 1 -> Buy)') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') diff --git a/completion/prefix.fish b/completion/prefix.fish index 975c7de..238fdbd 100644 --- a/completion/prefix.fish +++ b/completion/prefix.fish @@ -6,7 +6,7 @@ complete -c prefix -l porcelain -d 'print FIX messages closer to standard format complete -c prefix -s r -l repeating -d 'Combine any repeating groups into a single field with a comma delimited value' complete -c prefix -s f -l strict -d 'Only consider full FIX messages containing both BeginString and Checksum' complete -c prefix -s s -l strip -d 'Strip the whitespace around the = in each field' -complete -c prefix -s t -l tag -d 'Translate tag numbers on non FIX message lines' +complete -c prefix -s t -l tag -d 'Translate tag numbers on non FIX message lines, if the entire line matches a tag name it will print it\'s number' complete -c prefix -s v -l value -d 'Translate the values of some tags (for Side: 1 -> Buy)' complete -c prefix -s h -l help -d 'Print help' complete -c prefix -s V -l version -d 'Print version' diff --git a/man/prefix.1 b/man/prefix.1 index d13626c..e24a8be 100644 --- a/man/prefix.1 +++ b/man/prefix.1 @@ -1,6 +1,6 @@ .ie \n(.g .ds Aq \(aq .el .ds Aq ' -.TH prefix 1 "prefix 1.2.0" +.TH prefix 1 "prefix 1.2.1" .SH NAME prefix \- A customizable pretty printer for FIX messages .SH SYNOPSIS @@ -38,7 +38,7 @@ Strip the whitespace around the = in each field Summarise each fix message based on an optional template .TP \fB\-t\fR, \fB\-\-tag\fR -Translate tag numbers on non FIX message lines +Translate tag numbers on non FIX message lines, if the entire line matches a tag name it will print it\*(Aqs number .TP \fB\-v\fR, \fB\-\-value\fR Translate the values of some tags (for Side: 1 \-> Buy) @@ -52,4 +52,4 @@ Print version [\fImessage\fR] FIX message to be parsed, if not provided will look for a message piped through stdin .SH VERSION -v1.2.0 +v1.2.1 diff --git a/src/command.rs b/src/command.rs index cf61dfa..05dfdd5 100644 --- a/src/command.rs +++ b/src/command.rs @@ -42,7 +42,7 @@ pub fn make_command() -> Command { .default_missing_value("") ) .arg( - arg!(-t --tag "Translate tag numbers on non FIX message lines") + arg!(-t --tag "Translate tag numbers on non FIX message lines, if the entire line matches a tag name it will print it's number") .action(ArgAction::SetTrue) ) .arg( diff --git a/src/prefix/mod.rs b/src/prefix/mod.rs index 1bc8de8..60c7881 100644 --- a/src/prefix/mod.rs +++ b/src/prefix/mod.rs @@ -192,6 +192,13 @@ fn parse_fix_msg(input: &str, regex: &Regex) -> FixMsg { } fn parse_tags(input: &str, regex: &Regex) -> String { + if input.chars().all(|c| !c.is_ascii_digit()) { + for (tag, tag_name) in tags::TAGS.iter().enumerate() { + if input.to_lowercase() == tag_name.to_lowercase() && !tag_name.is_empty() { + return tag.to_string(); + } + } + } let mut result = input.to_owned(); for m in regex.find_iter(input) { let tag = m.as_str().parse::().unwrap();