prompt
A prompt for manual user input
Example (choices)
no available example in current language
no available example in current language
no 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}`
}
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 language
no available example in current language
Installation
dagger install github.com/pjmagee/dagger-prompt@v0.1.0
Entrypoint
Return Type
Prompt !
Example
dagger -m github.com/pjmagee/dagger-prompt@ea2567d574588f123bf32f4672fc263efe099f9b call \
func (m *myModule) example() *Prompt {
return dag.
Prompt()
}
@function
def example() -> dag.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 \
outcome
func (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 \
input
func (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 string2
func (m *myModule) example(ci bool, msg string, input string, match string, choices []string) *Prompt {
return dag.
Prompt().
WithOptions(ci, msg, input, match, choices)
}
@function
def example(ci: bool, msg: str, input: str, match: str, choices: List[str]) -> dag.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 boolean
func (m *myModule) example(ci bool) *Prompt {
return dag.
Prompt().
WithCi(ci)
}
@function
def example(ci: bool) -> dag.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 string
func (m *myModule) example(msg string) *Prompt {
return dag.
Prompt().
WithMsg(msg)
}
@function
def example(msg: str) -> dag.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 string
func (m *myModule) example(input string) *Prompt {
return dag.
Prompt().
WithInput(input)
}
@function
def example(input: str) -> dag.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 string
func (m *myModule) example(match string) *Prompt {
return dag.
Prompt().
WithMatch(match)
}
@function
def example(match: str) -> dag.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 string2
func (m *myModule) example(choices []string) *Prompt {
return dag.
Prompt().
WithChoices(choices)
}
@function
def example(choices: List[str]) -> dag.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 \
execute
func (m *myModule) example() *PromptResult {
return dag.
Prompt().
Execute()
}
@function
def example() -> dag.PromptResult:
return (
dag.prompt()
.execute()
)
@func()
example(): PromptResult {
return dag
.prompt()
.execute()
}