-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Luiz Carvalho <[email protected]>
- Loading branch information
Showing
2 changed files
with
35 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,51 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
"os" | ||
"strings" | ||
"time" | ||
|
||
"github.com/lcarva/festoji/app" | ||
) | ||
|
||
var ( | ||
n = flag.Int("n", 1, "number of characters/days to display") | ||
day = flag.Bool("day", false, "display day for the character") | ||
rule = flag.Bool("rule", false, "display matching rule for the character") | ||
) | ||
|
||
func main() { | ||
flag.Parse() | ||
|
||
userConfigPath := os.ExpandEnv("${HOME}/.festoji.yaml") | ||
config, errConfig := app.NewConfig(userConfigPath) | ||
if errConfig != nil { | ||
log.Fatal("Unable to load configuration: ", errConfig) | ||
return | ||
} | ||
character, errChar := app.Character(time.Now(), config) | ||
if errChar != nil { | ||
log.Fatal("Unable to get character: ", errChar) | ||
return | ||
|
||
t := time.Now() | ||
for i := 0; i < *n; i++ { | ||
character, ruleName, errChar := app.Character(t, config) | ||
if errChar != nil { | ||
log.Fatal("Unable to get character: ", errChar) | ||
return | ||
} | ||
|
||
var parts []string | ||
if *day { | ||
parts = append(parts, t.Format("02/Jan/2006")) | ||
} | ||
parts = append(parts, character) | ||
if *rule { | ||
parts = append(parts, ruleName) | ||
} | ||
fmt.Println(strings.Join(parts, " ")) | ||
|
||
t = t.Add(time.Hour * 24) | ||
} | ||
fmt.Println(character) | ||
|
||
} |