diff --git a/Cargo.lock b/Cargo.lock index 7bf1f02..a1705b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.14" +version = "0.6.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" dependencies = [ "anstyle", "anstyle-parse", @@ -28,52 +28,53 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" [[package]] name = "anstyle-parse" -version = "0.2.4" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" dependencies = [ "windows-sys", ] [[package]] name = "anstyle-wincon" -version = "3.0.3" +version = "3.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" dependencies = [ "anstyle", + "once_cell_polyfill", "windows-sys", ] [[package]] name = "clap" -version = "4.5.9" +version = "4.5.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" +checksum = "be92d32e80243a54711e5d7ce823c35c41c9d929dc4ab58e1276f625841aadf9" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.9" +version = "4.5.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" +checksum = "707eab41e9622f9139419d573eca0900137718000c517d47da73045f54331c3d" dependencies = [ "anstream", "anstyle", @@ -83,24 +84,24 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.8" +version = "4.5.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b4be9c4c4b1f30b78d8a750e0822b6a6102d97e62061c583a6c1dea2dfb33ae" +checksum = "a5abde44486daf70c5be8b8f8f1b66c49f86236edf6fa2abadb4d961c4c6229a" dependencies = [ "clap", ] [[package]] name = "clap_lex" -version = "0.7.1" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" [[package]] name = "clap_mangen" -version = "0.2.22" +version = "0.2.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50dde5bc0c853d6248de457e5eb6e5a674a54b93810a34ded88d882ca1fe2de" +checksum = "e2fb6d3f935bbb9819391528b0e7cf655e78a0bc7a7c3d227211a1d24fc11db1" dependencies = [ "clap", "roff", @@ -108,47 +109,60 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.1" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "fastrand" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "is_terminal_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "memchr" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" [[package]] name = "phf" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +checksum = "913273894cec178f401a31ec4b656318d95473527be05c0752cc41cdc32be8b7" dependencies = [ "phf_macros", "phf_shared", + "serde", ] [[package]] name = "phf_generator" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +checksum = "2cbb1126afed61dd6368748dae63b1ee7dc480191c6262a3b4ff1e29d86a6c5b" dependencies = [ + "fastrand", "phf_shared", - "rand", ] [[package]] name = "phf_macros" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +checksum = "d713258393a82f091ead52047ca779d37e5766226d009de21696c4e667044368" dependencies = [ "phf_generator", "phf_shared", @@ -159,9 +173,9 @@ dependencies = [ [[package]] name = "phf_shared" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +checksum = "06005508882fb681fd97892ecff4b7fd0fee13ef1aa569f8695dae7ab9099981" dependencies = [ "siphasher", ] @@ -179,42 +193,27 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" - [[package]] name = "regex" -version = "1.10.5" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -224,9 +223,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -235,21 +234,41 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "roff" -version = "0.2.1" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88f8660c1ff60292143c98d08fc6e2f654d722db50410e3f3797d40baaf9d8f3" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "siphasher" -version = "0.3.11" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "strsim" @@ -259,9 +278,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.72" +version = "2.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" dependencies = [ "proc-macro2", "quote", @@ -270,9 +289,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "utf8parse" @@ -282,9 +301,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] diff --git a/Cargo.toml b/Cargo.toml index e4b8799..a2540eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,9 +25,9 @@ categories = [ ] [dependencies] -regex = "1.10.5" -clap = "4.5.9" -phf = { version = "0.11.2", features = ["macros"] } +regex = "1.11.1" +clap = "4.5.41" +phf = { version = "0.12.1", features = ["macros"] } [build-dependencies] clap = "4.5.9" diff --git a/completion/_prefix b/completion/_prefix index f676860..4f0d4bb 100644 --- a/completion/_prefix +++ b/completion/_prefix @@ -17,10 +17,10 @@ _prefix() { _arguments "${_arguments_options[@]}" : \ '-c+[Adds colour to the delimiter and = in for FIX fields, auto will colour only when printing directly into a tty]:when:(always auto never)' \ '--color=[Adds colour to the delimiter and = in for FIX fields, auto will colour only when printing directly into a tty]:when:(always auto never)' \ -'-d+[Set delimiter string to print after each FIX field]:delimiter: ' \ -'--delimiter=[Set delimiter string to print after each FIX field]:delimiter: ' \ -'-S+[Summarise each fix message based on an optional template]' \ -'--summary=[Summarise each fix message based on an optional template]' \ +'-d+[Set delimiter string to print after each FIX field]:delimiter:_default' \ +'--delimiter=[Set delimiter string to print after each FIX field]:delimiter:_default' \ +'-S+[Summarise each fix message based on a template, if summary is provided with no template then it uses '\''35'\'']' \ +'--summary=[Summarise each fix message based on a template, if summary is provided with no template then it uses '\''35'\'']' \ '-o[Only print FIX messages]' \ '--only-fix[Only print FIX messages]' \ '--porcelain[print FIX messages closer to standard format, same as --delimiter \\x01 --strip]' \ @@ -38,7 +38,7 @@ _prefix() { '--help[Print help]' \ '-V[Print version]' \ '--version[Print version]' \ -'*::message -- FIX message to be parsed, if not provided will look for a message piped through stdin:' \ +'*::message -- FIX message to be parsed, if not provided will look for a message piped through stdin:_default' \ && ret=0 } diff --git a/completion/_prefix.ps1 b/completion/_prefix.ps1 index c538e9b..1eed727 100644 --- a/completion/_prefix.ps1 +++ b/completion/_prefix.ps1 @@ -21,29 +21,29 @@ Register-ArgumentCompleter -Native -CommandName 'prefix' -ScriptBlock { $completions = @(switch ($command) { 'prefix' { - [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Adds colour to the delimiter and = in for FIX fields, auto will colour only when printing directly into a tty') - [CompletionResult]::new('--color', 'color', [CompletionResultType]::ParameterName, 'Adds colour to the delimiter and = in for FIX fields, auto will colour only when printing directly into a tty') - [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Set delimiter string to print after each FIX field') - [CompletionResult]::new('--delimiter', 'delimiter', [CompletionResultType]::ParameterName, 'Set delimiter string to print after each FIX field') - [CompletionResult]::new('-S', 'S ', [CompletionResultType]::ParameterName, 'Summarise each fix message based on an optional template') - [CompletionResult]::new('--summary', 'summary', [CompletionResultType]::ParameterName, 'Summarise each fix message based on an optional template') - [CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'Only print FIX messages') - [CompletionResult]::new('--only-fix', 'only-fix', [CompletionResultType]::ParameterName, 'Only print FIX messages') - [CompletionResult]::new('--porcelain', 'porcelain', [CompletionResultType]::ParameterName, 'print FIX messages closer to standard format, same as --delimiter \x01 --strip') - [CompletionResult]::new('-r', 'r', [CompletionResultType]::ParameterName, 'Combine any repeating groups into a single field with a comma delimited value') - [CompletionResult]::new('--repeating', 'repeating', [CompletionResultType]::ParameterName, 'Combine any repeating groups into a single field with a comma delimited value') - [CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'Only consider full FIX messages containing both BeginString and Checksum') - [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, 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') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') - [CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('-c', '-c', [CompletionResultType]::ParameterName, 'Adds colour to the delimiter and = in for FIX fields, auto will colour only when printing directly into a tty') + [CompletionResult]::new('--color', '--color', [CompletionResultType]::ParameterName, 'Adds colour to the delimiter and = in for FIX fields, auto will colour only when printing directly into a tty') + [CompletionResult]::new('-d', '-d', [CompletionResultType]::ParameterName, 'Set delimiter string to print after each FIX field') + [CompletionResult]::new('--delimiter', '--delimiter', [CompletionResultType]::ParameterName, 'Set delimiter string to print after each FIX field') + [CompletionResult]::new('-S', '-S ', [CompletionResultType]::ParameterName, 'Summarise each fix message based on a template, if summary is provided with no template then it uses ''35''') + [CompletionResult]::new('--summary', '--summary', [CompletionResultType]::ParameterName, 'Summarise each fix message based on a template, if summary is provided with no template then it uses ''35''') + [CompletionResult]::new('-o', '-o', [CompletionResultType]::ParameterName, 'Only print FIX messages') + [CompletionResult]::new('--only-fix', '--only-fix', [CompletionResultType]::ParameterName, 'Only print FIX messages') + [CompletionResult]::new('--porcelain', '--porcelain', [CompletionResultType]::ParameterName, 'print FIX messages closer to standard format, same as --delimiter \x01 --strip') + [CompletionResult]::new('-r', '-r', [CompletionResultType]::ParameterName, 'Combine any repeating groups into a single field with a comma delimited value') + [CompletionResult]::new('--repeating', '--repeating', [CompletionResultType]::ParameterName, 'Combine any repeating groups into a single field with a comma delimited value') + [CompletionResult]::new('-f', '-f', [CompletionResultType]::ParameterName, 'Only consider full FIX messages containing both BeginString and Checksum') + [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, 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') + [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') break } }) diff --git a/completion/prefix.bash b/completion/prefix.bash index a5ec6e9..24ede92 100644 --- a/completion/prefix.bash +++ b/completion/prefix.bash @@ -1,12 +1,16 @@ _prefix() { local i cur prev opts cmd COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + cur="$2" + else + cur="${COMP_WORDS[COMP_CWORD]}" + fi + prev="$3" cmd="" opts="" - for i in ${COMP_WORDS[@]} + for i in "${COMP_WORDS[@]:0:COMP_CWORD}" do case "${cmd},${i}" in ",$1") diff --git a/completion/prefix.fish b/completion/prefix.fish index 238fdbd..737a82c 100644 --- a/completion/prefix.fish +++ b/completion/prefix.fish @@ -1,6 +1,8 @@ -complete -c prefix -s c -l color -d 'Adds colour to the delimiter and = in for FIX fields, auto will colour only when printing directly into a tty' -r -f -a "{always\t'',auto\t'',never\t''}" +complete -c prefix -s c -l color -d 'Adds colour to the delimiter and = in for FIX fields, auto will colour only when printing directly into a tty' -r -f -a "always\t'' +auto\t'' +never\t''" complete -c prefix -s d -l delimiter -d 'Set delimiter string to print after each FIX field' -r -complete -c prefix -s S -l summary -d 'Summarise each fix message based on an optional template' -r +complete -c prefix -s S -l summary -d 'Summarise each fix message based on a template, if summary is provided with no template then it uses \'35\'' -r complete -c prefix -s o -l only-fix -d 'Only print FIX messages' complete -c prefix -l porcelain -d 'print FIX messages closer to standard format, same as --delimiter \\x01 --strip' complete -c prefix -s r -l repeating -d 'Combine any repeating groups into a single field with a comma delimited value' diff --git a/man/prefix.1 b/man/prefix.1 index e24a8be..f9915fa 100644 --- a/man/prefix.1 +++ b/man/prefix.1 @@ -35,7 +35,7 @@ Only consider full FIX messages containing both BeginString and Checksum Strip the whitespace around the = in each field .TP \fB\-S\fR, \fB\-\-summary\fR=\fItemplate\fR -Summarise each fix message based on an optional template +Summarise each fix message based on a template, if summary is provided with no template then it uses \*(Aq35\*(Aq .TP \fB\-t\fR, \fB\-\-tag\fR Translate tag numbers on non FIX message lines, if the entire line matches a tag name it will print it\*(Aqs number diff --git a/src/command.rs b/src/command.rs index 05dfdd5..59a6a35 100644 --- a/src/command.rs +++ b/src/command.rs @@ -38,8 +38,8 @@ pub fn make_command() -> Command { .action(ArgAction::SetTrue) ) .arg( - arg!(-S --summary [template] "Summarise each fix message based on an optional template") - .default_missing_value("") + arg!(-S --summary [template] "Summarise each fix message based on a template, if summary is provided with no template then it uses '35'") + .default_missing_value("35") ) .arg( 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") diff --git a/src/prefix/mod.rs b/src/prefix/mod.rs index 60c7881..6549ae3 100644 --- a/src/prefix/mod.rs +++ b/src/prefix/mod.rs @@ -191,10 +191,19 @@ fn parse_fix_msg(input: &str, regex: &Regex) -> FixMsg { FixMsg::Full(result) } +fn eq_ignore_ascii_case(a: &str, b: &str) -> bool { + if a.len() != b.len() { + return false; + } + a.bytes() + .zip(b.bytes()) + .all(|(ac, bc)| ac.eq_ignore_ascii_case(&bc)) +} + 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() { + if eq_ignore_ascii_case(input, tag_name) && !tag_name.is_empty() { return tag.to_string(); } } @@ -271,14 +280,6 @@ fn format_to_summary( .to_string(); } } - if field.tag == 35 { - let msg_type = tags::MSG_TYPES - .iter() - .find(|(msg_type, _)| *msg_type == field.value) - .expect("Invalid msg type") - .1; - result = format!("{msg_type} {result}"); - } } result } @@ -425,13 +426,15 @@ mod tests { repeating: false, strict: false, strip: false, - summary: Some(String::from("for 55")), + summary: Some(String::from("35 for 55")), tag: false, - value: false, + value: true, }; - let regex_by_tag = - HashMap::::from([(String::from("55"), Regex::new(r"\b55\b").unwrap())]); + let regex_by_tag = HashMap::::from([ + (String::from("35"), Regex::new(r"\b35\b").unwrap()), + (String::from("55"), Regex::new(r"\b55\b").unwrap()), + ]); let result = format_to_summary(&input, ®ex_by_tag, &flags); let expected = String::from("NewOrderSingle for EUR/USD"); assert_eq!(result, expected); diff --git a/src/prefix/tags.rs b/src/prefix/tags.rs index 657ddab..c95cfe1 100644 --- a/src/prefix/tags.rs +++ b/src/prefix/tags.rs @@ -960,102 +960,6 @@ pub const TAGS: [&str; 957] = [ "LegInterestAccrualDate", ]; -pub const MSG_TYPES: [(&str, &str); 93] = [ - ("0", "Heartbeat"), - ("1", "TestRequest"), - ("2", "ResendRequest"), - ("3", "Reject"), - ("4", "SequenceReset"), - ("5", "Logout"), - ("6", "IOI"), - ("7", "Advertisement"), - ("8", "ExecutionReport"), - ("9", "OrderCancelReject"), - ("a", "QuoteStatusRequest"), - ("A", "Logon"), - ("AA", "DerivativeSecurityList"), - ("AB", "NewOrderMultileg"), - ("AC", "MultilegOrderCancel/Replace"), - ("AD", "TradeCaptureReportRequest"), - ("AE", "TradeCaptureReport"), - ("AF", "OrderMassStatusRequest"), - ("AG", "QuoteRequestReject"), - ("AH", "RFQRequest"), - ("AI", "QuoteStatusReport"), - ("AJ", "QuoteResponse"), - ("AK", "Confirmation"), - ("AL", "PositionMaintenanceRequest"), - ("AM", "PositionMaintenanceReport"), - ("AN", "RequestForPositions"), - ("AO", "RequestforPositionsAck"), - ("AP", "PositionReport"), - ("AQ", "TradeCaptureReportRequestAck"), - ("AR", "TradeCaptureReportAck"), - ("AS", "AllocationReport"), - ("AT", "AllocationReportAck"), - ("AU", "ConfirmationAck"), - ("AV", "SettlementInstructionRequest"), - ("AW", "AssignmentReport"), - ("AX", "CollateralRequest"), - ("AY", "CollateralAssignment"), - ("AZ", "CollateralResponse"), - ("b", "MassQuoteAcknowledgement"), - ("B", "News"), - ("BA", "CollateralReport"), - ("BB", "CollateralInquiry"), - ("BC", "NetworkCounterpartySystemStatusRequest"), - ("BD", "NetworkCounterpartySystemStatusResponse"), - ("BE", "UserRequest"), - ("BF", "UserResponse"), - ("BG", "CollateralInquiryAck"), - ("BH", "ConfirmationRequest"), - ("c", "SecurityDefinitionRequest"), - ("C", "Email"), - ("d", "SecurityDefinition"), - ("D", "NewOrderSingle"), - ("e", "SecurityStatusRequest"), - ("E", "NewOrderList"), - ("f", "SecurityStatus"), - ("F", "OrderCancelRequest"), - ("g", "TradingSessionStatusRequest"), - ("G", "OrderCancel/ReplaceRequest"), - ("h", "TradingSessionStatus"), - ("H", "OrderStatusRequest"), - ("i", "MassQuote"), - ("j", "BusinessMessageReject"), - ("J", "AllocationInstruction"), - ("k", "BidRequest"), - ("K", "ListCancelRequest"), - ("l", "BidResponse"), - ("L", "ListExecute"), - ("m", "ListStrikePrice"), - ("M", "ListStatusRequest"), - ("n", "XMLMessage"), - ("N", "ListStatus"), - ("o", "RegistrationInstructions"), - ("p", "RegistrationInstructionsResponse"), - ("P", "AllocationInstructionAck"), - ("q", "OrderMassCancelRequest"), - ("Q", "Don'tKnowTrade"), - ("r", "OrderMassCancelReport"), - ("R", "QuoteRequest"), - ("s", "NewOrderCross"), - ("S", "Quote"), - ("t", "CrossOrderCancel/ReplaceRequest"), - ("T", "SettlementInstructions"), - ("u", "CrossOrderCancelRequest"), - ("v", "SecurityTypeRequest"), - ("V", "MarketDataRequest"), - ("w", "SecurityTypes"), - ("W", "MarketData-Snapshot/FullRefresh"), - ("x", "SecurityListRequest"), - ("X", "MarketData-IncrementalRefresh"), - ("y", "SecurityList"), - ("Y", "MarketDataRequestReject"), - ("z", "DerivativeSecurityListRequest"), - ("Z", "QuoteCancel"), -]; - pub static VALUES: phf::Map<&'static str, &'static str> = phf_map! { "4-B" => "Buy", "4-S" => "Sell", diff --git a/test/test.sh b/test/test.sh index 8f4f7fa..5d20174 100644 --- a/test/test.sh +++ b/test/test.sh @@ -4,11 +4,13 @@ diff_tool="nvim -d " arg_sets=( "--summary --tag" - "--summary=55" + "--summary" "35 55" "--summary=54 --value" - "--summary" "54 some 55" "--only-fix" + "--summary" "35 54 some 55" "--only-fix" "--tag" "--value" + "--value --repeating" + "--repeating" "--strict" "--strict --only-fix" "--strip" @@ -17,6 +19,8 @@ arg_sets=( ) msg_sets=( + "Non FIX line with a tag: 55" + "BeginString" "8=FIX.4.4|35=A|34=1092|49=TESTBUY1|56=TESTSELL1|10=178|" "8=FIX.4.4^35=D^34=192^49=SENDER^56=TARGET^55=EURUSD^10=123^" "8=FIX.4.4|35=8|34=192|49=SENDER|56=TARGET|55=EURUSD|54=1" @@ -40,16 +44,16 @@ trap cleanup EXIT for args in "${arg_sets[@]}"; do for msg in "${msg_sets[@]}"; do # Make it easier to see which command is different. - echo "==========" $args $msg "==========">> "$before_file" - echo "==========" $args $msg "==========" >> "$after_file" + echo "==========" $args "$msg" "==========" >>"$before_file" + echo "==========" $args "$msg" "==========" >>"$after_file" - $before_cmd $msg $args >>"$before_file" - $after_cmd $msg $args >>"$after_file" + $before_cmd "$msg" $args >>"$before_file" + $after_cmd "$msg" $args >>"$after_file" done cat test/test.txt | $before_cmd $args >>"$before_file" cat test/test.txt | $after_cmd $args >>"$after_file" done -cat test/test.txt | $before_cmd --summary 55 | sort | uniq --count >>"$before_file" -cat test/test.txt | $after_cmd --summary 55 | sort | uniq --count >>"$after_file" +cat test/test.txt | $before_cmd --summary "35 55" -v | sort | uniq --count >>"$before_file" +cat test/test.txt | $after_cmd --summary "35 55" -v | sort | uniq --count >>"$after_file" $diff_tool "$before_file" "$after_file"