-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
141 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package cmd | ||
|
||
import "github.com/f1bonacc1/process-compose/src/config" | ||
|
||
var pcFlags *config.Flags | ||
|
||
func init() { | ||
pcFlags = config.NewFlags() | ||
} |
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
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
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
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
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
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
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,74 @@ | ||
package config | ||
|
||
import "math" | ||
|
||
const ( | ||
// DefaultRefreshRate represents the refresh interval. | ||
DefaultRefreshRate = 2 // secs | ||
|
||
// DefaultLogLevel represents the default log level. | ||
DefaultLogLevel = "info" | ||
|
||
// DefaultPortNum represents the default port number. | ||
DefaultPortNum = 8080 | ||
|
||
// DefaultAddress represents the default address. | ||
DefaultAddress = "localhost" | ||
|
||
// DefaultLogLength represents the default log length. | ||
DefaultLogLength = 1000 | ||
) | ||
|
||
const ( | ||
PortEnvVarName = "PC_PORT_NUM" | ||
TuiEnvVarName = "PC_DISABLE_TUI" | ||
ConfigEnvVarName = "PC_CONFIG_FILES" | ||
) | ||
|
||
// Flags represents PC configuration flags. | ||
type Flags struct { | ||
RefreshRate *int | ||
PortNum *int | ||
Address *string | ||
LogLevel *string | ||
LogFile *string | ||
LogLength *int | ||
LogFollow *bool | ||
LogTailLength *int | ||
Headless *bool | ||
Command *string | ||
AllNamespaces *bool | ||
ReadOnly *bool | ||
Write *bool | ||
NoDependencies *bool | ||
} | ||
|
||
// NewFlags returns new configuration flags. | ||
func NewFlags() *Flags { | ||
return &Flags{ | ||
RefreshRate: intPtr(DefaultRefreshRate), | ||
Headless: boolPtr(GetTuiDefault()), | ||
PortNum: intPtr(getPortDefault()), | ||
Address: strPtr(DefaultAddress), | ||
LogLength: intPtr(DefaultLogLength), | ||
LogLevel: strPtr(DefaultLogLevel), | ||
LogFile: strPtr(GetLogFilePath()), | ||
LogFollow: boolPtr(false), | ||
LogTailLength: intPtr(math.MaxInt), | ||
AllNamespaces: boolPtr(false), | ||
ReadOnly: boolPtr(false), | ||
NoDependencies: boolPtr(false), | ||
} | ||
} | ||
|
||
func boolPtr(b bool) *bool { | ||
return &b | ||
} | ||
|
||
func intPtr(i int) *int { | ||
return &i | ||
} | ||
|
||
func strPtr(s string) *string { | ||
return &s | ||
} |
Oops, something went wrong.