提交 a289a59a 编写于 作者: H heyanlong

Initialization project

上级
.idea
bin
\ No newline at end of file
# Example:
# make build
# make install
.PHONY: build install
build:
GO_BUILD_FLAGS="-v" ./scripts/build
./bin/swctl --version
\ No newline at end of file
Apache SkyWalking CLI
===============
<img src="http://skywalking.apache.org/assets/logo.svg" alt="Sky Walking logo" height="90px" align="right" />
The CLI for [Apache SkyWalking](https://github.com/apache/skywalking).
\ No newline at end of file
package main
import (
"os"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/apache/skywalking-cli/logger"
)
var log *logrus.Logger
func init() {
log = logger.Log
}
func main() {
app := cli.NewApp()
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
Usage: "path of settings.yml config. Use the file in the same folder as default.",
},
}
app.Commands = []cli.Command{serviceCmd}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
package main
import (
"github.com/apache/skywalking-cli/swctl/service"
"github.com/urfave/cli"
)
var serviceCmd = cli.Command{
Name: "service",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "list",
Usage: "list all available services.",
},
},
Action: func(c *cli.Context) {
ctl := service.NewService(c)
err := ctl.Exec()
if err != nil {
log.Fatal(err)
}
},
}
module github.com/apache/skywalking-cli
go 1.13
require (
github.com/lytics/logrus v0.0.0-20170528191427-4389a17ed024 // indirect
github.com/sirupsen/logrus v1.4.2
github.com/urfave/cli v1.22.1
)
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/lytics/logrus v0.0.0-20170528191427-4389a17ed024 h1:QaKVrqyQRNPbdBNCpiU0Ei3iDQko3qoiUUXMiTWhzZM=
github.com/lytics/logrus v0.0.0-20170528191427-4389a17ed024/go.mod h1:SkQviJ2s7rFyzyuxdVp6osZceHOabU91ZhKsEXF0RWg=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
package logger
import (
"os"
"github.com/sirupsen/logrus"
)
var Log *logrus.Logger
func init() {
if Log == nil {
Log = logrus.New()
}
Log.SetOutput(os.Stdout)
Log.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
TimestampFormat: "2006-01-02 15:04:05",
})
}
#!/usr/bin/env bash
cli_build() {
out="bin"
CGO_ENABLED=0 go build $GO_BUILD_FLAGS \
-o "${out}/swctl" cmd/* || return
}
if echo "$0" | grep "build$" > /dev/null; then
cli_build
fi
\ No newline at end of file
package service
func (s *service) showList() error {
return nil
}
package service
import (
"github.com/urfave/cli"
)
type service struct {
flag *cli.Context
list bool
}
func NewService(flag *cli.Context) *service {
return &service{
flag: flag,
list: flag.Bool("list"),
}
}
func (s *service) Exec() (err error) {
if s.list {
err = s.showList()
}
return
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册