File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -151,13 +151,15 @@ Gotify-CLI will search the following paths for a config file:
151151| ----- | ----------- | ------- |
152152| token | an application token (a client token will not work) | ` A4ZudDRdLT40L5X ` |
153153| url | the URL to your [ gotify/server] [ gotify/server ] | ` https://gotify.example.com ` |
154+ | defaultPriority | Default priority ( set to 0 if not present) | ` 6 ` |
154155
155156### Config example
156157
157158``` json
158159{
159160 "token" : " A4ZudDRdLT40L5X" ,
160- "url" : " https://gotify.example.com"
161+ "url" : " https://gotify.example.com" ,
162+ "defaultPriority" : 6
161163}
162164```
163165
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ func Config() cli.Command {
2121 }
2222 fmt .Println ("Used Config:" , conf .FromLocation )
2323 fmt .Println ("URL:" , conf .URL )
24+ fmt .Println ("Default Priority:" , conf .DefaultPriority )
2425 fmt .Println ("Token:" , conf .Token )
2526 },
2627 }
Original file line number Diff line number Diff line change @@ -35,10 +35,13 @@ func doInit(ctx *cli.Context) {
3535 hr ()
3636 token := inputToken (gotify .NewClient (serverURL , utils .CreateHTTPClient ()))
3737 hr ()
38+ defaultPriority := inputDefaultPriority ()
39+ hr ()
3840
3941 conf := & config.Config {
40- URL : serverURL .String (),
41- Token : token ,
42+ URL : serverURL .String (),
43+ Token : token ,
44+ DefaultPriority : defaultPriority ,
4245 }
4346
4447 pathToWrite , err := config .ExistingConfig (config .GetLocations ())
@@ -204,6 +207,20 @@ func inputRawToken(gotify *api.GotifyREST) string {
204207
205208}
206209
210+ func inputDefaultPriority () int {
211+ for {
212+ defaultPriorityStr := inputString ("Default Priority [0-10]: " )
213+ defaultPriority , err := strconv .Atoi (defaultPriorityStr )
214+ if err != nil || (defaultPriority > 10 || defaultPriority < 0 ) {
215+ erred ("Priority needs to be a number between 0 and 10." )
216+ continue
217+ } else {
218+ return defaultPriority
219+ }
220+ hr ()
221+ }
222+ }
223+
207224func inputServerURL () * url.URL {
208225 for {
209226 rawURL := inputString ("Gotify URL: " )
Original file line number Diff line number Diff line change @@ -64,6 +64,10 @@ func doPush(ctx *cli.Context) {
6464 stringURL = conf .URL
6565 }
6666
67+ if ! ctx .IsSet ("priority" ) {
68+ priority = conf .DefaultPriority
69+ }
70+
6771 msg := models.MessageExternal {
6872 Message : msgText ,
6973 Title : title ,
Original file line number Diff line number Diff line change 11package config
22
33type Config struct {
4- Token string `json:"token"`
5- URL string `json:"url"`
6- FromLocation string `json:"-"`
4+ Token string `json:"token"`
5+ URL string `json:"url"`
6+ DefaultPriority int `json:"defaultPriority"`
7+ FromLocation string `json:"-"`
78}
You can’t perform that action at this time.
0 commit comments