Skip to content

Commit

Permalink
add parsing empty arguments for symbols/types.
Browse files Browse the repository at this point in the history
It uses: all, wildcard
  • Loading branch information
kosyloa committed Oct 24, 2023
1 parent ed02e27 commit 90a1133
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
</CommandLineArgument>
<CommandLineArgument
argument = "Dump tapeK2.tape[speed=max] all all -t ios_tapeK2.tape -q"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "Dump tapeK2.tape[speed=max] -t ios_tapeK2.tape -q"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
Expand Down
26 changes: 21 additions & 5 deletions Samples/PerfTestCL/Arguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum ArgumentParserException: Error {

class Arguments {
private let allParameters: [String]
private let namelessParameters: [String]

public lazy var properties: [String: String] = {
var properties = [String: String]()
Expand Down Expand Up @@ -62,27 +63,42 @@ Cmd \(cmd) contains not enough \(cmd.count - 1) arguments. Expected \(requiredNu
}
// 0 Arg is path to executed app
self.allParameters = Array(cmd[1..<cmd.count])
if let firstNamedParameter = cmd.firstIndex(where: { str in
str.hasPrefix("-")
}) {
self.namelessParameters = Array(cmd[1..<firstNamedParameter])
} else {
self.namelessParameters = self.allParameters
}
}

public subscript(index: Int) -> String {
allParameters[index]
namelessParameters[index]
}

public var count: Int {
allParameters.count
namelessParameters.count
}

public func parseTypes(at index: Int) -> [EventCode] {
if allParameters[2] == "all" {
if namelessParameters.count <= index {
return EventCode.allCases
}

if namelessParameters[2] == "all" {
return EventCode.allCases
}
return allParameters[2].split(separator: ",").compactMap { str in
return namelessParameters[2].split(separator: ",").compactMap { str in
return EventCode(string: String(str))
}
}

public func parseSymbols(at index: Int) -> [Symbol] {
let symbols = allParameters[index]
if namelessParameters.count <= index {
return [WildcardSymbol.all]
}

let symbols = namelessParameters[index]
if symbols.lowercased() == "all" {
return [WildcardSymbol.all]
}
Expand Down
13 changes: 10 additions & 3 deletions Samples/PerfTestCL/DumpTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,19 @@ class DumpTool: ToolsCommand {
Where:
<address> is a URL to Schedule API defaults file
<types> is comma-separated list of dxfeed event types ({eventTypeNames}).
If <types> is not specified, creates a subscription for all available event types.
<symbol> is comma-separated list of symbol names to get events for (e.g. ""IBM,AAPL,MSFT"").
for Candle event specify symbol with aggregation like in ""AAPL{{=d}}""
for Candle event specify symbol with aggregation like in ""AAPL{{=d}}""
If <symbol> is not specified, the wildcard symbol is used.
Usage:
Dump <address> [<options>]
Dump <address> <types> [<options>]
Dump <address> <types> <symbols> [<options>]
sample: Dump demo.dxfeed.com:7300 quote AAPL,IBM,ETH/USD:GDAX -t "tape_test.txt[format=text]"
Sample: Dump demo.dxfeed.com:7300 quote AAPL,IBM,ETH/USD:GDAX -t "tape_test.txt[format=text]"
Sample: Dump tapeK2.tape[speed=max] all all -q -t ios_tapeK2.tape
Sample: Dump tapeK2.tape[speed=max] -q -t ios_tapeK2.tape
sample: Dump tapeK2.tape[speed=max] all all -q -t ios_tapeK2.tape
"""
var publisher: DXPublisher?
var isQuite = false
Expand Down

0 comments on commit 90a1133

Please sign in to comment.