-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from ADorigi/fix/add-interactive-configure
fix: interactive configuration
- Loading branch information
Showing
4 changed files
with
123 additions
and
24 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
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,41 @@ | ||
package input | ||
|
||
import ( | ||
"github.com/adorigi/checkctl/pkg/config" | ||
"github.com/charmbracelet/huh" | ||
) | ||
|
||
func GetConfigurationFromForm() (*config.Configuration, error) { | ||
|
||
var apiKey string | ||
var apiEndpoint string | ||
var utilizationAnalyzerEndpoint string | ||
var outputFormat string | ||
|
||
form := huh.NewForm( | ||
huh.NewGroup( | ||
huh.NewInput().Title("Enter API key").Value(&apiKey), | ||
huh.NewInput().Title("Enter API endpoint").Value(&apiEndpoint), | ||
huh.NewInput().Title("Enter utilization analyzer endpoint").Value(&utilizationAnalyzerEndpoint), | ||
huh.NewSelect[string](). | ||
Title("Select output format"). | ||
Options( | ||
huh.NewOption("JSON", "json"), | ||
). | ||
Value(&outputFormat), | ||
), | ||
) | ||
|
||
err := form.Run() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return config.NewConfiguration( | ||
outputFormat, | ||
apiEndpoint, | ||
utilizationAnalyzerEndpoint, | ||
apiKey, | ||
), nil | ||
|
||
} |