This repository has been archived by the owner on Jun 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.fs
59 lines (49 loc) · 1.64 KB
/
Program.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
module Program
open System.Reflection
open Argu
open Clam
open Clam.Types
let runCommands (parser: ArgumentParser<CliArguments>) (args: string array) =
let parsingResult = parser.Parse args
match parsingResult.GetAllResults() with
| [ List ] -> Commands.runList ()
| [ Add subCommand ] ->
let opts =
{ repositoryName = subCommand.GetResult(RepositoryName)
branch =
subCommand.TryGetResult(Branch)
|> Option.flatten
|> Option.defaultValue "main" }
Commands.runAdd opts
| [ Update subCommand ] ->
let opts =
{ repositoryName = subCommand.GetResult(RepositoryName)
branch =
subCommand.TryGetResult(Branch)
|> Option.flatten
|> Option.defaultValue "main" }
Commands.runUpdate opts
| [ Remove repositoryName ] -> Commands.runRemove repositoryName
| [ New subCommand ] ->
let opts =
{ projectName = subCommand.GetResult(ProjectName)
templateName = subCommand.GetResult(Template) }
Commands.runNewProject opts
| [ Version ] ->
let version =
Assembly.GetEntryAssembly().GetName().Version
printfn $"{version.Major}.{version.Minor}.{version.Revision}"
| _ ->
let helpText = parser.PrintUsage()
printfn $"{helpText}"
[<EntryPoint>]
let main args =
try
let parser = ArgumentParser.Create<CliArguments>()
runCommands parser args
Database.closeDatabase ()
with
| ex ->
eprintfn $"{ex.Message}"
Database.closeDatabase ()
0