Skip to content

Commit b8156c6

Browse files
committed
Update main proc
1 parent ef06f0b commit b8156c6

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

cmd/trygolang/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ func main() {
5959

6060
var cmd command.Cmd
6161
if args.ExampleName != "" {
62-
cmd = NewRunOnceCommand(NewRunOnceArgs(args.ExampleName, mapping))
62+
cmd = command.NewRunOnceCommand(command.NewRunOnceArgs(args.ExampleName, mapping))
6363
} else {
64-
cmd = NewRunLoopCommand(NewRunLoopArgs(args, mapping))
64+
cmd = command.NewRunLoopCommand(command.NewRunLoopArgs(args.OneTime, mapping))
6565
}
6666

6767
if err := cmd.Run(); err != nil {

pkg/command/errs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package command
22

33
import (
44
"fmt"

pkg/command/exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package command
22

33
import (
44
"fmt"

pkg/command/runloop.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package command
22

33
import (
44
"bufio"
@@ -18,15 +18,15 @@ type (
1818

1919
// RunLoopArgs -- RunLoopCommand の引数データを表します.
2020
RunLoopArgs struct {
21-
MainArgs *Args // 引数
22-
Mapping mappings.ExampleMapping // マッピング情報
21+
OneTime bool // 一回実行で完了するかどうか
22+
Mapping mappings.ExampleMapping // マッピング情報
2323
}
2424
)
2525

2626
// NewRunLoopArgs -- 新しい RunLoopArgs を生成して返します.
27-
func NewRunLoopArgs(mainArgs *Args, mapping mappings.ExampleMapping) *RunLoopArgs {
27+
func NewRunLoopArgs(oneTime bool, mapping mappings.ExampleMapping) *RunLoopArgs {
2828
a := new(RunLoopArgs)
29-
a.MainArgs = mainArgs
29+
a.OneTime = oneTime
3030
a.Mapping = mapping
3131
return a
3232
}
@@ -41,8 +41,8 @@ func NewRunLoopCommand(args *RunLoopArgs) *RunLoopCommand {
4141
// Run -- 実行します.
4242
func (c *RunLoopCommand) Run() error {
4343
var (
44-
mainArgs = c.Args.MainArgs
45-
mapping = c.Args.Mapping
44+
oneTime = c.Args.OneTime
45+
mapping = c.Args.Mapping
4646
)
4747

4848
fmt.Print("ENTER EXAMPLE NAME: ")
@@ -104,7 +104,7 @@ func (c *RunLoopCommand) Run() error {
104104
}
105105
}
106106

107-
if mainArgs.OneTime {
107+
if oneTime {
108108
break
109109
}
110110

pkg/command/runonce.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package command
22

33
import (
44
"github.com/devlights/try-golang/pkg/mappings"

0 commit comments

Comments
 (0)