@@ -3,18 +3,12 @@ package main
33import (
44 "github.com/urfave/cli/v2"
55 "github.com/xEtarusx/xplane-gateway-downloader/app"
6- "github.com/xEtarusx/xplane-gateway-downloader/config"
76 "log"
87 "os"
98)
109
1110func main () {
12- cfg , err := config .LoadConfig ("config.json" )
13- if err != nil {
14- log .Fatal (err )
15- }
16-
17- config .GlobalConfig = cfg
11+ action := app.Action {}
1812
1913 a := & cli.App {
2014 Name : "X-Plane Gateway Downloader" ,
@@ -23,10 +17,18 @@ func main() {
2317 Description : "Update airport sceneries from the X-Plane Gateway" ,
2418 Commands : []* cli.Command {
2519 {
26- Name : "install" ,
27- Usage : "Install a new airport scenery pack" ,
28- Action : app .ActionInstall ,
20+ Name : "install" ,
21+ Usage : "Install a new airport scenery pack" ,
22+ Action : func (c * cli.Context ) error {
23+ return action .Process (c , app .ActionInstall )
24+ },
2925 Flags : []cli.Flag {
26+ & cli.StringFlag {
27+ Name : "config" ,
28+ Aliases : []string {"c" },
29+ Usage : "The `path` to the config.json" ,
30+ Value : "config.json" ,
31+ },
3032 & cli.StringFlag {
3133 Name : "icao" ,
3234 Aliases : []string {"i" },
@@ -35,15 +37,33 @@ func main() {
3537 },
3638 },
3739 {
38- Name : "update" ,
39- Usage : "Update all installed airport scenery packs" ,
40- Action : app .ActionUpdate ,
40+ Name : "update" ,
41+ Usage : "Update all installed airport scenery packs" ,
42+ Action : func (c * cli.Context ) error {
43+ return action .Process (c , app .ActionUpdate )
44+ },
45+ Flags : []cli.Flag {
46+ & cli.StringFlag {
47+ Name : "config" ,
48+ Aliases : []string {"c" },
49+ Usage : "The `path` to the config.json" ,
50+ Value : "config.json" ,
51+ },
52+ },
4153 },
4254 {
43- Name : "uninstall" ,
44- Usage : "Uninstall an installed airport scenery pack" ,
45- Action : app .ActionUninstall ,
55+ Name : "uninstall" ,
56+ Usage : "Uninstall an installed airport scenery pack" ,
57+ Action : func (c * cli.Context ) error {
58+ return action .Process (c , app .ActionUninstall )
59+ },
4660 Flags : []cli.Flag {
61+ & cli.StringFlag {
62+ Name : "config" ,
63+ Aliases : []string {"c" },
64+ Usage : "The `path` to the config.json" ,
65+ Value : "config.json" ,
66+ },
4767 & cli.StringFlag {
4868 Name : "icao" ,
4969 Aliases : []string {"i" },
@@ -52,10 +72,18 @@ func main() {
5272 },
5373 },
5474 {
55- Name : "config" ,
56- Usage : "Configure the application" ,
57- Action : app .ActionConfig ,
75+ Name : "config" ,
76+ Usage : "Configure the application" ,
77+ Action : func (c * cli.Context ) error {
78+ return action .Process (c , app .ActionConfig )
79+ },
5880 Flags : []cli.Flag {
81+ & cli.StringFlag {
82+ Name : "config" ,
83+ Aliases : []string {"c" },
84+ Usage : "The `path` to the config.json" ,
85+ Value : "config.json" ,
86+ },
5987 & cli.StringFlag {
6088 Name : "custom-scenery-folder" ,
6189 Aliases : []string {"csf" },
@@ -71,12 +99,7 @@ func main() {
7199 },
72100 }
73101
74- err = a .Run (os .Args )
75- if err != nil {
76- log .Fatal (err )
77- }
78-
79- err = config .SaveConfig ("config.json" )
102+ err := a .Run (os .Args )
80103 if err != nil {
81104 log .Fatal (err )
82105 }
0 commit comments