first commit
This commit is contained in:
25
example/cmd/cancel/main.go
Normal file
25
example/cmd/cancel/main.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
||||
"gitoa.ru/go-4devs/console"
|
||||
"gitoa.ru/go-4devs/console/example/pkg/command"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
ch := make(chan os.Signal, 1)
|
||||
defer close(ch)
|
||||
|
||||
signal.Notify(ch, os.Interrupt)
|
||||
|
||||
go func() {
|
||||
<-ch
|
||||
cancel()
|
||||
}()
|
||||
console.Execute(ctx, command.Long())
|
||||
}
|
||||
21
example/cmd/console/main.go
Normal file
21
example/cmd/console/main.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitoa.ru/go-4devs/console"
|
||||
"gitoa.ru/go-4devs/console/example/pkg/command"
|
||||
)
|
||||
|
||||
func main() {
|
||||
console.
|
||||
New().
|
||||
Add(
|
||||
command.Hello(),
|
||||
command.Args(),
|
||||
command.Hidden(),
|
||||
command.Namespace(),
|
||||
command.CreateUser(false),
|
||||
).
|
||||
Execute(context.Background())
|
||||
}
|
||||
12
example/cmd/single/main.go
Normal file
12
example/cmd/single/main.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitoa.ru/go-4devs/console"
|
||||
"gitoa.ru/go-4devs/console/example/pkg/command"
|
||||
)
|
||||
|
||||
func main() {
|
||||
console.Execute(context.Background(), command.Hello())
|
||||
}
|
||||
Reference in New Issue
Block a user