refactor: rename console to gconsole

This commit is contained in:
tiglog 2023-10-15 00:54:45 +08:00
parent 29e12c1aa6
commit d953b99b62
12 changed files with 19 additions and 19 deletions

View File

@ -5,7 +5,7 @@
// Distributed under terms of the MIT license. // Distributed under terms of the MIT license.
// //
package console package gconsole
import ( import (
"fmt" "fmt"

View File

@ -5,7 +5,7 @@
// Distributed under terms of the MIT license. // Distributed under terms of the MIT license.
// //
package console package gconsole
import ( import (
"flag" "flag"

View File

@ -5,7 +5,7 @@
// Distributed under terms of the MIT license. // Distributed under terms of the MIT license.
// //
package console package gconsole
import "flag" import "flag"

View File

@ -5,7 +5,7 @@
// Distributed under terms of the MIT license. // Distributed under terms of the MIT license.
// //
package console package gconsole
import ( import (
"errors" "errors"

View File

@ -5,7 +5,7 @@
// Distributed under terms of the MIT license. // Distributed under terms of the MIT license.
// //
package console package gconsole
import ( import (
"errors" "errors"

View File

@ -5,7 +5,7 @@
// Distributed under terms of the MIT license. // Distributed under terms of the MIT license.
// //
package console package gconsole
import "fmt" import "fmt"

View File

@ -5,14 +5,14 @@
// Distributed under terms of the MIT license. // Distributed under terms of the MIT license.
// //
package console package gconsole
import ( import (
"fmt" "fmt"
"os" "os"
) )
type ConsoleApp struct { type App struct {
name string name string
version string version string
desc string desc string
@ -20,8 +20,8 @@ type ConsoleApp struct {
about ActionHandler about ActionHandler
} }
func New(name, desc string) *ConsoleApp { func New(name, desc string) *App {
app := &ConsoleApp{ app := &App{
name: name, name: name,
version: "v0.1.0", version: "v0.1.0",
desc: desc, desc: desc,
@ -35,40 +35,40 @@ func New(name, desc string) *ConsoleApp {
return app return app
} }
func (s *ConsoleApp) GetCmds() map[string]ICommand { func (s *App) GetCmds() map[string]ICommand {
return s.cmds return s.cmds
} }
func (s *ConsoleApp) GetName() string { func (s *App) GetName() string {
return s.name return s.name
} }
func (s *ConsoleApp) GetDesc() string { func (s *App) GetDesc() string {
return s.desc return s.desc
} }
func (s *ConsoleApp) GetVersion() string { func (s *App) GetVersion() string {
return s.version return s.version
} }
func (s *ConsoleApp) AddCmd(cmd ICommand) { func (s *App) AddCmd(cmd ICommand) {
s.cmds[cmd.GetName()] = cmd s.cmds[cmd.GetName()] = cmd
} }
func (s *ConsoleApp) HasCmd(cmd string) bool { func (s *App) HasCmd(cmd string) bool {
_, ok := s.cmds[cmd] _, ok := s.cmds[cmd]
return ok return ok
} }
func (s *ConsoleApp) SetExtraAbout(about ActionHandler) { func (s *App) SetExtraAbout(about ActionHandler) {
s.about = about s.about = about
} }
func (s *ConsoleApp) GetExtraAbout() ActionHandler { func (s *App) GetExtraAbout() ActionHandler {
return s.about return s.about
} }
func (s *ConsoleApp) Run(args []string) { func (s *App) Run(args []string) {
cmd := "list" cmd := "list"
if len(args) == 1 { if len(args) == 1 {
args = []string{cmd} args = []string{cmd}