File tree 4 files changed +26
-53
lines changed
4 files changed +26
-53
lines changed Original file line number Diff line number Diff line change 1
1
package config
2
2
3
- import (
4
- "io/ioutil"
5
- "os"
6
-
7
- "gopkg.in/yaml.v3"
8
- )
9
-
10
- const CONFIG_PATH = "/.config/pomodorox/config.yaml"
11
-
12
3
type Config struct {
13
- Timers struct {
14
- WorkLoops int `yaml:"workLoops"`
15
- TimeWorkLoops int `yaml:"timeWorkLoops"`
16
- TimePause int `yaml:"timePause"`
17
- }
18
- }
19
-
20
- func getConf (file []byte ) (* Config , error ) {
21
- conf := & Config {}
22
- err := yaml .Unmarshal (file , conf )
23
- if err != nil {
24
- return nil , err
25
- }
26
-
27
- return conf , nil
28
- }
29
-
30
- func openConfigFile () []byte {
31
- homePath := os .Getenv ("HOME" )
32
- file , err := ioutil .ReadFile (homePath + CONFIG_PATH )
33
- if err != nil {
34
- panic (err )
35
- }
36
-
37
- return file
38
- }
39
-
40
- func GetConf () (* Config , error ) {
41
- conf , err := getConf (openConfigFile ())
42
- if err != nil {
43
- return nil , err
44
- }
45
-
46
- return conf , nil
4
+ TimeWork int
5
+ TimePause int
6
+ QtyWorkLoops int
47
7
}
Original file line number Diff line number Diff line change @@ -39,17 +39,17 @@ func printInfo(pomo *Pomodorox) {
39
39
40
40
func StartPomodorox (config * config.Config ) {
41
41
work := timeLoop {
42
- loops : config .Timers . WorkLoops ,
42
+ loops : config .QtyWorkLoops ,
43
43
completedLoops : 0 ,
44
44
}
45
45
46
46
pause := timeLoop {
47
- loops : config .Timers . WorkLoops - 1 ,
47
+ loops : config .QtyWorkLoops - 1 ,
48
48
completedLoops : 0 ,
49
49
}
50
50
51
- workTime := time .Duration (config .Timers . TimeWorkLoops )
52
- pauseTime := time .Duration (config .Timers . TimePause )
51
+ workTime := time .Duration (config .TimeWork )
52
+ pauseTime := time .Duration (config .TimePause )
53
53
54
54
pomo := Pomodorox {
55
55
workLoops : work ,
Original file line number Diff line number Diff line change @@ -7,8 +7,6 @@ cp pomodorox "$HOME/.local/bin/"
7
7
echo " 🍅 Copy assets folder."
8
8
cp assets/tomato.png " $HOME /.local/share/icons/"
9
9
echo " 🍅 Create a config file."
10
- mkdir -p " $HOME /.config/pomodorox/"
11
- cp config_sample.yaml " $HOME /.config/pomodorox/config.yaml"
12
10
echo " DONE 😎"
13
11
14
12
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
+ "fmt"
5
+ "os"
6
+ "strconv"
7
+
4
8
"github.com/pablotrianda/pomodox/cmd/config"
5
9
"github.com/pablotrianda/pomodox/cmd/pomodorox"
6
10
)
7
11
8
12
func main () {
9
- config , err := config . GetConf ()
10
- if err != nil {
11
- panic ( err )
13
+ if ! ( len ( os . Args ) > 1 ) {
14
+ fmt . Println ( "YOU MUST USE PARAMS!!" )
15
+ os . Exit ( 1 )
12
16
}
13
- pomodorox .StartPomodorox (config )
17
+
18
+ timeWork , _ := strconv .Atoi (os .Args [1 ])
19
+ timePause , _ := strconv .Atoi (os .Args [2 ])
20
+ qtyWorkLoops , _ := strconv .Atoi (os .Args [3 ])
21
+
22
+ conf := & config.Config {
23
+ TimeWork : timeWork ,
24
+ TimePause : timePause ,
25
+ QtyWorkLoops : qtyWorkLoops ,
26
+ }
27
+
28
+ pomodorox .StartPomodorox (conf )
14
29
}
You can’t perform that action at this time.
0 commit comments