@@ -18,10 +18,12 @@ import (
18
18
type aatConfig struct {
19
19
coords bool
20
20
monochrome bool
21
- unit iface.UnitSystem
21
+ compact bool
22
+
23
+ unit iface.UnitSystem
22
24
}
23
25
24
- //TODO: replace s parameter with printf interface?
26
+ // TODO: replace s parameter with printf interface?
25
27
func aatPad (s string , mustLen int ) (ret string ) {
26
28
ansiEsc := regexp .MustCompile ("\033 .*?m" )
27
29
ret = s
@@ -283,9 +285,13 @@ func (c *aatConfig) formatCond(cur []string, cond iface.Cond, current bool) (ret
283
285
},
284
286
}
285
287
286
- icon , ok := codes [cond .Code ]
287
- if ! ok {
288
- log .Fatalln ("aat-frontend: The following weather code has no icon:" , cond .Code )
288
+ icon := make ([]string , 5 )
289
+ if ! c .compact {
290
+ var ok bool
291
+ icon , ok = codes [cond .Code ]
292
+ if ! ok {
293
+ log .Fatalln ("aat-frontend: The following weather code has no icon:" , cond .Code )
294
+ }
289
295
}
290
296
291
297
desc := cond .Desc
@@ -352,19 +358,45 @@ func (c *aatConfig) printDay(day iface.Day) (ret []string) {
352
358
}
353
359
354
360
dateFmt := "┤ " + day .Date .Format ("Mon 02. Jan" ) + " ├"
355
- ret = append ([]string {
356
- " ┌─────────────┐ " ,
357
- "┌──────────────────────────────┬───────────────────────" + dateFmt + "───────────────────────┬──────────────────────────────┐" ,
358
- "│ Morning │ Noon └──────┬──────┘ Evening │ Night │" ,
359
- "├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤" },
360
- ret ... )
361
- return append (ret ,
362
- "└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘" )
361
+ if ! c .compact {
362
+ ret = append ([]string {
363
+ " ┌─────────────┐ " ,
364
+ "┌──────────────────────────────┬───────────────────────" + dateFmt + "───────────────────────┬──────────────────────────────┐" ,
365
+ "│ Morning │ Noon └──────┬──────┘ Evening │ Night │" ,
366
+ "├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤" },
367
+ ret ... )
368
+ ret = append (ret ,
369
+ "└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘" )
370
+ } else {
371
+ merge := func (src string , into string ) string {
372
+ ret := []rune (into )
373
+ for k , v := range src {
374
+ ret [k ] = v
375
+ }
376
+ return string (ret )
377
+ }
378
+
379
+ spaces := (len (ret [0 ]) / 4 ) - 3
380
+ bar := strings .Repeat ("─" , spaces )
381
+
382
+ ret = append ([]string {
383
+ day .Date .Format ("Mon 02. Jan" ),
384
+ "┌" + merge ("Morning" , bar ) + "┬" + merge ("Noon" , bar ) + "┬" + merge ("Evening" , bar ) + "┬" + merge ("Night" , bar ) + "┐" ,
385
+ }, ret ... )
386
+
387
+ ret = append (ret ,
388
+ "└" + bar + "┴" + bar + "┴" + bar + "┴" + bar + "┘" ,
389
+ )
390
+ }
391
+
392
+ return ret
363
393
}
364
394
365
395
func (c * aatConfig ) Setup () {
366
396
flag .BoolVar (& c .coords , "aat-coords" , false , "aat-frontend: Show geo coordinates" )
367
397
flag .BoolVar (& c .monochrome , "aat-monochrome" , false , "aat-frontend: Monochrome output" )
398
+
399
+ flag .BoolVar (& c .compact , "aat-compact" , false , "aat-frontend: Compact output" )
368
400
}
369
401
370
402
func (c * aatConfig ) Render (r iface.Data , unitSystem iface.UnitSystem ) {
0 commit comments