prompt
A prompt for manual user input
Example (Input)
no available example in current language// Prompt_Input is a function that demonstrates how to use the Prompt() function
func (m *Examples) Prompt_Input(userInput string, ci bool) string {
result := dag.Prompt().
WithMsg("Do you want to continue? (y/n)"). // A custom message for the prompt
WithInput(userInput). // pass in from the ci pipeline
WithMatch("y"). // A custom regex match for the user input
WithCi(ci). // disabled ci mode will open a terminal prompt
Execute()
outcome, _ := result.Outcome(context.Background()) // true or false if input matched the regex
input, _ := result.Input(context.Background()) // The user input
return "Outcome: " + strconv.FormatBool(outcome) + ", Input: " + input
}no available example in current language @func()
async prompt_input(user_input: string, ci: boolean): Promise<string> {
const result = dag.prompt().withMsg("Continue? (y/n)").withInput(user_input).withCi(ci).execute()
const outcome = await result.outcome()
const input = await result.input()
return `Outcome: ${outcome}, Input: ${input}`
}Example (Choice)
no available example in current language// Prompt_Choice is a function that demonstrates how to use the Prompt() function
func (m *Examples) Prompt_Choice(userInput string) string {
result := dag.Prompt().
WithChoices([]string{"Option 1", "Option 2", "Option 3"}). // A list of custom choices
WithMsg("Select an option"). // A custom message for the prompt
WithInput(userInput). // pass in from the ci pipeline
WithCi(true). // disabled ci mode will open a terminal prompt
Execute()
outcome, _ := result.Outcome(context.Background()) // true or false if input was a valid choice
input, _ := result.Input(context.Background()) // The selected choice
return "Outcome: " + strconv.FormatBool(outcome) + ", Input: " + input
}no available example in current languageno available example in current languageExample (choices)
no available example in current languageno available example in current languageno available example in current language @func()
async prompt_choices(): Promise<string> {
const result = dag.prompt().withChoices(["apple", "bear", "orange"]).withCi(false).execute()
const outcome = await result.outcome()
const input = await result.input()
return `Outcome: ${outcome}, Input: ${input}`
}Example (Options)
no available example in current language// Prompt_Options is a function that demonstrates how to use the Prompt() function
func (m *Examples) Prompt_Options(userInput string, ci bool) string {
result := dag.Prompt().WithOptions(ci, "Continue? (y/n)", userInput, "y", []string{}).Execute()
outcome, _ := result.Outcome(context.Background()) // true or false if input was a valid choice
input, _ := result.Input(context.Background()) // The selected choice
return "Outcome: " + strconv.FormatBool(outcome) + ", Input: " + input
}no available example in current language @func()
async prompt_options(user_input: string = "y", ci: boolean = true): Promise<string> {
const result = dag.prompt().withOptions({
ci: ci,
msg: "Continue? (y/n)",
input: user_input,
match: "y",
choices: []
}).execute()
const outcome = await result.outcome()
const input = await result.input()
return `Outcome: ${outcome}, Input: ${input}`
}Installation
dagger install github.com/pjmagee/dagger-prompt@v0.1.0Entrypoint
Return Type
Prompt ! Example
dagger -m github.com/pjmagee/dagger-prompt@ea2567d574588f123bf32f4672fc263efe099f9b call \
func (m *MyModule) Example() *dagger.Prompt {
return dag.
Prompt()
}@function
def example() -> dagger.Prompt:
return (
dag.prompt()
)@func()
example(): Prompt {
return dag
.prompt()
}Types
Options 🔗
Result 🔗
outcome() 🔗
Return Type
Boolean ! Example
dagger -m github.com/pjmagee/dagger-prompt@ea2567d574588f123bf32f4672fc263efe099f9b call \
execute \
outcomefunc (m *MyModule) Example(ctx context.Context) bool {
return dag.
Prompt().
Execute().
Outcome(ctx)
}@function
async def example() -> bool:
return await (
dag.prompt()
.execute()
.outcome()
)@func()
async example(): Promise<boolean> {
return dag
.prompt()
.execute()
.outcome()
}input() 🔗
Return Type
String ! Example
dagger -m github.com/pjmagee/dagger-prompt@ea2567d574588f123bf32f4672fc263efe099f9b call \
execute \
inputfunc (m *MyModule) Example(ctx context.Context) string {
return dag.
Prompt().
Execute().
Input(ctx)
}@function
async def example() -> str:
return await (
dag.prompt()
.execute()
.input()
)@func()
async example(): Promise<string> {
return dag
.prompt()
.execute()
.input()
}Prompt 🔗
withOptions() 🔗
Return Type
Prompt !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| ci | Boolean ! | true | No description provided |
| msg | String ! | "Continue? (y/n)" | No description provided |
| input | String ! | "" | No description provided |
| match | String ! | "y" | No description provided |
| choices | [String ! ] ! | [] | No description provided |
Example
dagger -m github.com/pjmagee/dagger-prompt@ea2567d574588f123bf32f4672fc263efe099f9b call \
with-options --ci boolean --msg string --input string --match string --choices string1 --choices string2func (m *MyModule) Example(ci bool, msg string, input string, match string, choices []string) *dagger.Prompt {
return dag.
Prompt().
WithOptions(ci, msg, input, match, choices)
}@function
def example(ci: bool, msg: str, input: str, match: str, choices: List[str]) -> dagger.Prompt:
return (
dag.prompt()
.with_options(ci, msg, input, match, choices)
)@func()
example(ci: boolean, msg: string, input: string, match: string, choices: string[]): Prompt {
return dag
.prompt()
.withOptions(ci, msg, input, match, choices)
}withCi() 🔗
Return Type
Prompt !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| ci | Boolean ! | - | No description provided |
Example
dagger -m github.com/pjmagee/dagger-prompt@ea2567d574588f123bf32f4672fc263efe099f9b call \
with-ci --ci booleanfunc (m *MyModule) Example(ci bool) *dagger.Prompt {
return dag.
Prompt().
WithCi(ci)
}@function
def example(ci: bool) -> dagger.Prompt:
return (
dag.prompt()
.with_ci(ci)
)@func()
example(ci: boolean): Prompt {
return dag
.prompt()
.withCi(ci)
}withMsg() 🔗
Return Type
Prompt !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| msg | String ! | - | No description provided |
Example
dagger -m github.com/pjmagee/dagger-prompt@ea2567d574588f123bf32f4672fc263efe099f9b call \
with-msg --msg stringfunc (m *MyModule) Example(msg string) *dagger.Prompt {
return dag.
Prompt().
WithMsg(msg)
}@function
def example(msg: str) -> dagger.Prompt:
return (
dag.prompt()
.with_msg(msg)
)@func()
example(msg: string): Prompt {
return dag
.prompt()
.withMsg(msg)
}withInput() 🔗
Return Type
Prompt !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| input | String ! | - | No description provided |
Example
dagger -m github.com/pjmagee/dagger-prompt@ea2567d574588f123bf32f4672fc263efe099f9b call \
with-input --input stringfunc (m *MyModule) Example(input string) *dagger.Prompt {
return dag.
Prompt().
WithInput(input)
}@function
def example(input: str) -> dagger.Prompt:
return (
dag.prompt()
.with_input(input)
)@func()
example(input: string): Prompt {
return dag
.prompt()
.withInput(input)
}withMatch() 🔗
Return Type
Prompt !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| match | String ! | - | No description provided |
Example
dagger -m github.com/pjmagee/dagger-prompt@ea2567d574588f123bf32f4672fc263efe099f9b call \
with-match --match stringfunc (m *MyModule) Example(match string) *dagger.Prompt {
return dag.
Prompt().
WithMatch(match)
}@function
def example(match: str) -> dagger.Prompt:
return (
dag.prompt()
.with_match(match)
)@func()
example(match: string): Prompt {
return dag
.prompt()
.withMatch(match)
}withChoices() 🔗
Return Type
Prompt !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| choices | [String ! ] ! | - | No description provided |
Example
dagger -m github.com/pjmagee/dagger-prompt@ea2567d574588f123bf32f4672fc263efe099f9b call \
with-choices --choices string1 --choices string2func (m *MyModule) Example(choices []string) *dagger.Prompt {
return dag.
Prompt().
WithChoices(choices)
}@function
def example(choices: List[str]) -> dagger.Prompt:
return (
dag.prompt()
.with_choices(choices)
)@func()
example(choices: string[]): Prompt {
return dag
.prompt()
.withChoices(choices)
}execute() 🔗
Return Type
Result ! Example
dagger -m github.com/pjmagee/dagger-prompt@ea2567d574588f123bf32f4672fc263efe099f9b call \
executefunc (m *MyModule) Example() *dagger.PromptResult {
return dag.
Prompt().
Execute()
}@function
def example() -> dagger.PromptResult:
return (
dag.prompt()
.execute()
)@func()
example(): PromptResult {
return dag
.prompt()
.execute()
}