generated from kurtosis-tech/package-template-repo
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add interfaces for context , logger and spinner
- Loading branch information
1 parent
cb78cd4
commit 038a934
Showing
6 changed files
with
151 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package common | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
type Logger interface { | ||
SetOutput(*os.File) | ||
Debug(errorCode int8, errorMessage string) | ||
Info(errorCode int8, errorMessage string) | ||
Warn(errorCode int8, errorMessage string) | ||
Error(errorCode int8, errorMessage string) | ||
Fatal(errorCode int8, errorMessage string) | ||
Infof(format string, errorCode int8, errorMessage string) | ||
Warnf(format string, errorCode int8, errorMessage string) | ||
Errorf(format string, errorCode int8, errorMessage string) | ||
Fatalf(format string, errorCode int8, errorMessage string) | ||
} | ||
|
||
type Spinner interface { | ||
SetMessage(message string, color string) | ||
SetColor(color string) | ||
Start(message string) | ||
Stop(message string) | ||
} | ||
|
||
type Context interface { | ||
CheckSkippedInstructions() | ||
CleanAll() | ||
Clean(enclaveName string) | ||
CreateEnclave(enclaveName string) | ||
GetEnclaves() []string | ||
GetSerializedData(response chan *kurtosis_core_rpc_api_bindings.StarlarkRunResponseLine) (string, map[string]string, map[string]bool, error) | ||
InitialiseKurtosisContext() | ||
StopServices() | ||
StopService() | ||
} | ||
|
||
type FileHandler interface { | ||
ReadFromFile(filePath string) ([]byte, error) | ||
ReadFromJson(filePath string, obj interface{}) (string, error) | ||
WriteToFile(filePath string, data []byte) error | ||
WriteToJson(filePath string, data interface{}) error | ||
} | ||
|
||
// CommandBuilder is an interface for building a Cobra command. | ||
type CommandBuilder interface { | ||
// AddCommand adds a subcommand to the command. | ||
AddCommand(cmd *cobra.Command) CommandBuilder | ||
|
||
// Add Persistant Bool Flag | ||
AddBoolPersistantFlag(p *bool, name string, value bool, usage string) CommandBuilder | ||
|
||
// Add Persistant Bool Flag with Short hand | ||
AddBoolPersistantFlagWithShortHand(p *bool, name string, value bool, usage string, shorthand string) CommandBuilder | ||
|
||
// Add Persistant String Flag | ||
AddStringPersistantFlag(p *string, name string, value string, usage string) CommandBuilder | ||
|
||
// Add Persistant String Flag with Short hand | ||
AddStringPersistantFlagWithShortHand(p *string, name string, shorthand string, value string, usage string) CommandBuilder | ||
|
||
// Add StringFlag adds a string flag to the command that persists | ||
AddStringFlag(name string, value string, usage string) CommandBuilder | ||
|
||
// Add StringFlag adds a string flag to the command that persists with short hand | ||
AddStringFlagWithShortHand(p *string, name string, shorthand string, value string, usage string) CommandBuilder | ||
|
||
// Add BooFlag adds a boolean flag to the command that persists | ||
AddBoolFlag(name string, value bool, usage string) CommandBuilder | ||
|
||
AddBoolFlagWithShortHand(name string, shorthand string, value bool, usage string) CommandBuilder | ||
|
||
// Build constructs and returns the Cobra command. | ||
Build() *cobra.Command | ||
|
||
// SetUse sets the Use field of the command. | ||
SetUse(use string) CommandBuilder | ||
|
||
// SetShort sets the Short field of the command. | ||
SetShort(short string) CommandBuilder | ||
|
||
// SetLong sets the Long field of the command. | ||
SetLong(long string) CommandBuilder | ||
|
||
// SetRun sets the Run field of the command. | ||
SetRun(run func(cmd *cobra.Command, args []string)) CommandBuilder | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters