refactor: rename console to gconsole
This commit is contained in:
parent
29e12c1aa6
commit
d953b99b62
@ -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"
|
@ -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"
|
@ -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"
|
||||||
|
|
@ -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"
|
@ -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"
|
@ -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"
|
||||||
|
|
@ -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}
|
Loading…
Reference in New Issue
Block a user