use a better naming for output functions

parent 683e53ef
......@@ -61,7 +61,7 @@ func runAttachCommand(cmd *cobra.Command, args []string) {
BoardUri: args[0],
SketchPath: path,
SearchTimeout: attachFlags.searchTimeout,
}, output.OutputTaskProgress())
}, output.TaskProgress())
if err != nil {
formatter.PrintError(err, "attach board error")
os.Exit(errorcodes.ErrGeneric)
......
......@@ -50,7 +50,7 @@ func runDetailsCommand(cmd *cobra.Command, args []string) {
formatter.PrintError(err, "Error getting board details")
os.Exit(errorcodes.ErrGeneric)
}
if output.OutputJSONOrElse(res) {
if output.JSONOrElse(res) {
outputDetailsResp(res)
}
}
......
......@@ -67,7 +67,7 @@ func runListCommand(cmd *cobra.Command, args []string) {
os.Exit(errorcodes.ErrNetwork)
}
if output.OutputJSONOrElse(resp) {
if output.JSONOrElse(resp) {
outputListResp(resp)
}
}
......
......@@ -58,7 +58,7 @@ func runListAllCommand(cmd *cobra.Command, args []string) {
os.Exit(errorcodes.ErrGeneric)
}
if output.OutputJSONOrElse(list) {
if output.JSONOrElse(list) {
outputBoardListAll(list)
}
}
......
......@@ -58,7 +58,7 @@ func runDownloadCommand(cmd *cobra.Command, args []string) {
Architecture: platformRef.Architecture,
Version: platformRef.Version,
}
_, err := core.PlatformDownload(context.Background(), platformDownloadreq, output.OutputProgressBar(),
_, err := core.PlatformDownload(context.Background(), platformDownloadreq, output.ProgressBar(),
globals.HTTPClientHeader)
if err != nil {
formatter.PrintError(err, "Error downloading "+args[i])
......
......@@ -60,8 +60,8 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
Architecture: platformRef.Architecture,
Version: platformRef.Version,
}
_, err := core.PlatformInstall(context.Background(), plattformInstallReq, output.OutputProgressBar(),
output.OutputTaskProgress(), globals.HTTPClientHeader)
_, err := core.PlatformInstall(context.Background(), plattformInstallReq, output.ProgressBar(),
output.TaskProgress(), globals.HTTPClientHeader)
if err != nil {
formatter.PrintError(err, "Error during install")
os.Exit(errorcodes.ErrGeneric)
......
......@@ -64,7 +64,7 @@ func runListCommand(cmd *cobra.Command, args []string) {
}
installed := resp.GetInstalledPlatform()
if installed != nil && len(installed) > 0 {
if output.OutputJSONOrElse(installed) {
if output.JSONOrElse(installed) {
outputInstalledCores(installed)
}
}
......
......@@ -63,7 +63,7 @@ func runSearchCommand(cmd *cobra.Command, args []string) {
}
coreslist := resp.GetSearchOutput()
if output.OutputJSONOrElse(coreslist) {
if output.JSONOrElse(coreslist) {
if len(coreslist) > 0 {
outputSearchCores(coreslist)
} else {
......
......@@ -49,7 +49,7 @@ func runUpdateIndexCommand(cmd *cobra.Command, args []string) {
_, err := commands.UpdateIndex(context.Background(), &rpc.UpdateIndexReq{
Instance: instance,
}, output.OutputProgressBar())
}, output.ProgressBar())
if err != nil {
formatter.PrintError(err, "Error updating index")
os.Exit(errorcodes.ErrGeneric)
......
......@@ -63,7 +63,7 @@ func runUpgradeCommand(cmd *cobra.Command, args []string) {
Instance: instance,
PlatformPackage: platformRef.Package,
Architecture: platformRef.Architecture,
}, output.OutputProgressBar(), output.OutputTaskProgress(),
}, output.ProgressBar(), output.TaskProgress(),
globals.HTTPClientHeader)
if err != nil {
formatter.PrintError(err, "Error during upgrade")
......
......@@ -26,7 +26,7 @@ var (
VersionInfo = version.NewInfo(filepath.Base(os.Args[0]))
// Config FIXMEDOC
Config *configs.Configuration
// YAMLConfigFile contains the path to the config file
YAMLConfigFile string
)
......
......@@ -37,14 +37,14 @@ func initInstance() *rpc.InitResp {
logrus.Info("Initializing package manager")
req := packageManagerInitReq()
resp, err := commands.Init(context.Background(), req, output.OutputProgressBar(), output.OutputTaskProgress(), globals.HTTPClientHeader)
resp, err := commands.Init(context.Background(), req, output.ProgressBar(), output.TaskProgress(), globals.HTTPClientHeader)
if err != nil {
formatter.PrintError(err, "Error initializing package manager")
os.Exit(errorcodes.ErrGeneric)
}
if resp.GetLibrariesIndexError() != "" {
commands.UpdateLibrariesIndex(context.Background(),
&rpc.UpdateLibrariesIndexReq{Instance: resp.GetInstance()}, output.OutputProgressBar())
&rpc.UpdateLibrariesIndexReq{Instance: resp.GetInstance()}, output.ProgressBar())
rescResp, err := commands.Rescan(context.Background(), &rpc.RescanReq{Instance: resp.GetInstance()})
if rescResp.GetLibrariesIndexError() != "" {
formatter.PrintErrorMessage("Error loading library index: " + rescResp.GetLibrariesIndexError())
......
......@@ -59,7 +59,7 @@ func runDownloadCommand(cmd *cobra.Command, args []string) {
Name: library.Name,
Version: library.Version.String(),
}
_, err := lib.LibraryDownload(context.Background(), libraryDownloadReq, output.OutputProgressBar(),
_, err := lib.LibraryDownload(context.Background(), libraryDownloadReq, output.ProgressBar(),
globals.HTTPClientHeader)
if err != nil {
formatter.PrintError(err, "Error downloading "+library.String())
......
......@@ -59,8 +59,8 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
Name: library.Name,
Version: library.Version.String(),
}
err := lib.LibraryInstall(context.Background(), libraryInstallReq, output.OutputProgressBar(),
output.OutputTaskProgress(), globals.HTTPClientHeader)
err := lib.LibraryInstall(context.Background(), libraryInstallReq, output.ProgressBar(),
output.TaskProgress(), globals.HTTPClientHeader)
if err != nil {
formatter.PrintError(err, "Error installing "+library.String())
os.Exit(errorcodes.ErrGeneric)
......
......@@ -67,7 +67,7 @@ func runListCommand(cmd *cobra.Command, args []string) {
}
if len(res.GetInstalledLibrary()) > 0 {
results := res.GetInstalledLibrary()
if output.OutputJSONOrElse(results) {
if output.JSONOrElse(results) {
if len(results) > 0 {
fmt.Println(outputListLibrary(results))
} else {
......
......@@ -64,7 +64,7 @@ func runSearchCommand(cmd *cobra.Command, args []string) {
os.Exit(errorcodes.ErrGeneric)
}
if output.OutputJSONOrElse(searchResp) {
if output.JSONOrElse(searchResp) {
results := searchResp.GetLibraries()
sort.Slice(results, func(i, j int) bool {
return results[i].Name < results[j].Name
......
......@@ -59,7 +59,7 @@ func runUninstallCommand(cmd *cobra.Command, args []string) {
Instance: instance,
Name: library.Name,
Version: library.Version.String(),
}, output.OutputTaskProgress())
}, output.TaskProgress())
if err != nil {
formatter.PrintError(err, "Error uninstalling "+library.String())
os.Exit(errorcodes.ErrGeneric)
......
......@@ -41,7 +41,7 @@ func initUpdateIndexCommand() *cobra.Command {
instance := instance.CreateInstaceIgnorePlatformIndexErrors()
err := commands.UpdateLibrariesIndex(context.Background(), &rpc.UpdateLibrariesIndexReq{
Instance: instance,
}, output.OutputProgressBar())
}, output.ProgressBar())
if err != nil {
formatter.PrintError(err, "Error updating library index")
os.Exit(errorcodes.ErrGeneric)
......
......@@ -50,7 +50,7 @@ func runUpgradeCommand(cmd *cobra.Command, args []string) {
err := lib.LibraryUpgradeAll(context.Background(), &rpc.LibraryUpgradeAllReq{
Instance: instance,
}, output.OutputProgressBar(), output.OutputTaskProgress(), globals.HTTPClientHeader)
}, output.ProgressBar(), output.TaskProgress(), globals.HTTPClientHeader)
if err != nil {
formatter.PrintError(err, "Error upgrading libraries")
os.Exit(errorcodes.ErrGeneric)
......
......@@ -33,10 +33,10 @@ import (
// TODO: Feed text output into colorable stdOut
var _ = colorable.NewColorableStdout()
// OutputJSONOrElse outputs the JSON encoding of v if the JSON output format has been
// JSONOrElse outputs the JSON encoding of v if the JSON output format has been
// selected by the user and returns false. Otherwise no output is produced and the
// function returns true.
func OutputJSONOrElse(v interface{}) bool {
func JSONOrElse(v interface{}) bool {
if !globals.OutputJSON {
return true
}
......@@ -49,9 +49,9 @@ func OutputJSONOrElse(v interface{}) bool {
return false
}
// OutputProgressBar returns a DownloadProgressCB that prints a progress bar.
// ProgressBar returns a DownloadProgressCB that prints a progress bar.
// If JSON output format has been selected, the callback outputs nothing.
func OutputProgressBar() commands.DownloadProgressCB {
func ProgressBar() commands.DownloadProgressCB {
if !globals.OutputJSON {
return NewDownloadProgressBarCB()
}
......@@ -60,9 +60,9 @@ func OutputProgressBar() commands.DownloadProgressCB {
}
}
// OutputTaskProgress returns a TaskProgressCB that prints the task progress.
// TaskProgress returns a TaskProgressCB that prints the task progress.
// If JSON output format has been selected, the callback outputs nothing.
func OutputTaskProgress() commands.TaskProgressCB {
func TaskProgress() commands.TaskProgressCB {
if !globals.OutputJSON {
return NewTaskProgressCB()
}
......
......@@ -39,7 +39,7 @@ func NewCommand() *cobra.Command {
}
func run(cmd *cobra.Command, args []string) {
if output.OutputJSONOrElse(globals.VersionInfo) {
if output.JSONOrElse(globals.VersionInfo) {
fmt.Printf("%s\n", globals.VersionInfo)
}
}
......@@ -41,9 +41,19 @@ require (
go.bug.st/downloader v1.1.0
go.bug.st/relaxed-semver v0.0.0-20181022103824-0265409c5852
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45
<<<<<<< HEAD
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
golang.org/x/net v0.0.0-20190311183353-d8887717615a
golang.org/x/text v0.3.0
=======
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 // indirect
golang.org/x/net v0.0.0-20190628185345-da137c7871d7
golang.org/x/sys v0.0.0-20190710143415-6ec70d6a5542 // indirect
golang.org/x/text v0.3.2
golang.org/x/tools v0.0.0-20190710184609-286818132824 // indirect
google.golang.org/appengine v1.4.0 // indirect
>>>>>>> use a better naming for output functions
google.golang.org/genproto v0.0.0-20190327125643-d831d65fe17d // indirect
google.golang.org/grpc v1.21.1
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce // indirect
......
......@@ -125,31 +125,48 @@ go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45/go.mod h1:dRSl/CVCTf56CkX
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 h1:QzoH/1pFpZguR8NrRHLcO6jKqfv2zpuSqZLgdm7ZmjI=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190628185345-da137c7871d7 h1:rTIdg5QFRR7XCaK4LCjBiPbx8j4DQRpdYMnGn/bJUEU=
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
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=
golang.org/x/sys v0.0.0-20190710143415-6ec70d6a5542 h1:6ZQFf1D2YYDDI7eSwW8adlkkavTB9sw5I24FVtEvNUQ=
golang.org/x/sys v0.0.0-20190710143415-6ec70d6a5542/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190710184609-286818132824 h1:dOGf5KG5e5tnConXcTAnHv2YgmYJtrYjN9b1cMC21TY=
golang.org/x/tools v0.0.0-20190710184609-286818132824/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment