@@ -6,17 +6,16 @@ import (
66
77 "github.com/zeropsio/zcli/src/cmd/scope"
88 "github.com/zeropsio/zcli/src/cmdBuilder"
9- "github.com/zeropsio/zcli/src/constants"
109 "github.com/zeropsio/zcli/src/entity/repository"
1110 "github.com/zeropsio/zcli/src/errorsx"
1211 "github.com/zeropsio/zcli/src/i18n"
13- "github.com/zeropsio/zcli/src/uxBlock "
12+ "github.com/zeropsio/zcli/src/printer "
1413 "github.com/zeropsio/zcli/src/uxBlock/styles"
1514 "github.com/zeropsio/zerops-go/errorCode"
1615)
1716
18- func ExecuteCmd () error {
19- return cmdBuilder .ExecuteRootCmd (rootCmd ())
17+ func ExecuteCmd () {
18+ cmdBuilder .ExecuteRootCmd (rootCmd ())
2019}
2120
2221func rootCmd () * cmdBuilder.Cmd {
@@ -34,29 +33,19 @@ func rootCmd() *cmdBuilder.Cmd {
3433 AddChildrenCmd (statusShowDebugLogsCmd ()).
3534 AddChildrenCmd (servicePushCmd ()).
3635 AddChildrenCmd (envCmd ()).
37- AddChildrenCmd (supportCmd ()).
36+ AddChildrenCmd (supportCmd ()).
3837 GuestRunFunc (func (ctx context.Context , cmdData * cmdBuilder.GuestCmdData ) error {
39- fmt .Println (`Welcome to zCli by Zerops!
40-
41- To unlock the full potential of zCLI, you need to log in using your Zerops account.
42- Logging in enables you to access various features and interact with Zerops services seamlessly.
43-
44- To log in, simply use the following command: zcli login <your_token>
45- Replace <your_token> with the authentication token generated from your Zerops account.
46- Once logged in, you'll be able to manage projects, deploy applications, configure VPN,
47- and much more directly from the command line interface.
48-
49- If you encounter any issues during the login process or have any questions,
50- feel free to find out how to contact our support team by running 'zcli support'.
51- ` )
38+ cmdData .Stdout .PrintLines (
39+ i18n .T (i18n .GuestWelcome ),
40+ printer .EmptyLine ,
41+ )
5242
5343 // print the default command help
5444 cmdData .PrintHelp ()
5545
5646 return nil
5747 }).
5848 LoggedUserRunFunc (func (ctx context.Context , cmdData * cmdBuilder.LoggedUserCmdData ) error {
59-
6049 var loggedUser string
6150 if info , err := cmdData .RestApiClient .GetUserInfo (ctx ); err != nil {
6251 loggedUser = err .Error ()
@@ -68,8 +57,7 @@ feel free to find out how to contact our support team by running 'zcli support'.
6857 }
6958 }
7059
71-
72- // TODO: krls - check whole block
60+ // TODO: krls - check whole block
7361 if cmdData .CliStorage .Data ().ScopeProjectId .Filled () {
7462 // project scope is set
7563 projectId , _ := cmdData .CliStorage .Data ().ScopeProjectId .Get ()
@@ -81,21 +69,24 @@ feel free to find out how to contact our support team by running 'zcli support'.
8169 return err
8270 }
8371 } else {
84- fmt . Print (i18n .T (i18n .ScopedProject ), err .Error ())
72+ cmdData . Stderr . PrintLines (i18n .T (i18n .ScopedProject ), err .Error ())
8573 }
8674 } else {
87- fmt . Print (i18n .T (i18n .ScopedProject ), fmt .Sprintf ("%s [%s]" , project .Name .String (), project .ID .Native ()))
75+ cmdData . Stdout . PrintLines (i18n .T (i18n .ScopedProject ), fmt .Sprintf ("%s [%s]" , project .Name .String (), project .ID .Native ()))
8876 }
8977 }
9078
91- var vpnStatusText string
79+ var vpnStatusText string
9280 if isVpnUp (ctx , cmdData .UxBlocks , 1 ) {
9381 vpnStatusText = i18n .T (i18n .VpnCheckingConnectionIsActive )
9482 } else {
9583 vpnStatusText = i18n .T (i18n .VpnCheckingConnectionIsNotActive )
9684 }
9785
98- fmt .Printf ("Welcome in Zerops!\n You are loged as %s \n and your %s.\n \n " , loggedUser , vpnStatusText )
86+ cmdData .Stdout .PrintLines (
87+ i18n .T (i18n .LoggedWelcome , loggedUser , vpnStatusText ),
88+ printer .EmptyLine ,
89+ )
9990
10091 // print the default command help
10192 cmdData .PrintHelp ()
@@ -104,26 +95,6 @@ feel free to find out how to contact our support team by running 'zcli support'.
10495 })
10596}
10697
107- func guestInfoPart (tableBody * uxBlock.TableBody ) {
108- cliDataFilePath , _ , err := constants .CliDataFilePath ()
109- if err != nil {
110- cliDataFilePath = err .Error ()
111- }
112- tableBody .AddStringsRow (i18n .T (i18n .StatusInfoCliDataFilePath ), cliDataFilePath )
113-
114- logFilePath , _ , err := constants .LogFilePath ()
115- if err != nil {
116- logFilePath = err .Error ()
117- }
118- tableBody .AddStringsRow (i18n .T (i18n .StatusInfoLogFilePath ), logFilePath )
119-
120- wgConfigFilePath , _ , err := constants .WgConfigFilePath ()
121- if err != nil {
122- wgConfigFilePath = err .Error ()
123- }
124- tableBody .AddStringsRow (i18n .T (i18n .StatusInfoWgConfigFilePath ), wgConfigFilePath )
125- }
126-
12798func getRootTemplate () string {
12899 return styles .CobraSectionColor ().SetString ("Usage:" ).String () + `{{if .Runnable}}
129100{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
0 commit comments