-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
130a339
commit 94da520
Showing
4 changed files
with
37 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,35 @@ | ||
|
||
open System.IO | ||
open System.Text.Json | ||
open Analog | ||
open Argu | ||
open Spectre.Console | ||
open Spectre.Console.Json | ||
|
||
type Argument = | ||
| [<AltCommandLine("-f"); Mandatory>] File of string | ||
| [<AltCommandLine("-t"); Unique>] Template of string | ||
|
||
interface IArgParserTemplate with | ||
member this.Usage = | ||
match this with | ||
| File _ -> "log file path." | ||
| Template _ -> "log file template." | ||
|
||
[<EntryPoint>] | ||
let main argv = | ||
0 | ||
let main argv = | ||
try | ||
let command = ArgumentParser.Create<Argument>().ParseCommandLine(argv) | ||
|
||
let template = | ||
command.TryGetResult Template | ||
|> Option.map (fun template -> Template.configuration |> Map.find template) | ||
|> Option.defaultValue (Template.configuration |> Seq.head |> _.Value) | ||
|
||
let render = JsonSerializer.Serialize >> JsonText >> AnsiConsole.Write | ||
let parse = Parser.parse render template.Pattern | ||
command.GetResults File |> Seq.iter (fun file -> File.OpenRead file |> parse) | ||
command |> ignore | ||
0 | ||
with :? ArguParseException as e -> | ||
eprintfn $"%s{e.Message}" | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
"type": "string" | ||
} | ||
}, | ||
"required": ["regex"] | ||
"required": ["pattern"] | ||
} | ||
} | ||
} |