cmd

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiTypeAfricastalking   = "AT_USSD"
	ApiTypeTruroute         = "TR_USSD"
	InteractiveDialTemplate = `Dialing app using:

	Phone: %s
	Url: %s
	SessionID:%s
	API Type: %s
`
)

Variables

This section is empty.

Functions

func AddStep

func AddStep(s *core.Session, step *core.Step)

AddStep adds step to session

func DialStep

func DialStep(expect string) *core.Step

DialStep is the first step in the session, dials the USSD service

func Execute

func Execute()

func ExecuteStep

func ExecuteStep(s *core.Step, session *core.Session) (string, error)

Execute executes a step and returns the result of the request may return an empty string ("") upon failure

func InvalidComponentIdError

func InvalidComponentIdError(step *core.Step, session *core.Session) error

func NewInteractiveSession

func NewInteractiveSession(d core.DialogussConfig) *core.Session

NewInteractiveSession creates a new interactive session that should be run using RunInteractive

func NewStep

func NewStep(i int, text string, expect string) *core.Step

NewStep a subsequent step in the session to the USSD service

func ResolveStepExpectedValue

func ResolveStepExpectedValue(s *core.Session, step *core.Step, store *ComponentStore) (string, error)

ResolveStepExpectedValue extracts step's expected value from the step or component store

func Run

func Run(s *core.Session, store *ComponentStore) error

Run runs the dialoguss session and executes the steps in each session

func RunInteractive

func RunInteractive(s *core.Session) error

RunInteractive runs and interactive session that prompts ufor user input

func UnexpectedResultError

func UnexpectedResultError(want string, have string) error

UnexpectedResultError unexpected result from the USSD application

Types

type ComponentStore

type ComponentStore map[string]map[string]string // namespace => component_id => expect

type Dialoguss

type Dialoguss core.Dialoguss

Dialoguss the main type for interacting with dialoguss sessions

func (*Dialoguss) GetComponents

func (d *Dialoguss) GetComponents() (*ComponentStore, error)

func (*Dialoguss) LoadConfig

func (d *Dialoguss) LoadConfig() error

LoadConfig loads configuration from YAML

func (*Dialoguss) Run

func (d *Dialoguss) Run() error

Run executes the sessions

func (*Dialoguss) RunAutomatedSessions

func (d *Dialoguss) RunAutomatedSessions() (int, error)

RunAutomatedSessions Loads the sessions for this application

Returns number of failed sessions

type DialogussCLI

type DialogussCLI struct {
	Globals

	Preview  PreviewCmd  `cmd:"" help:"Generate a preview of the dialoguss sessions using USSD Studio"`
	Run      RunCmd      `cmd:"" help:"Run a dialoguss test from a file"`
	Simulate SimulateCmd `cmd:"" help:"Simulate interaction with a USSD server in the command-line from a file"`
}

type Globals

type Globals struct {
	File        string `help:"Location of configuration file" default:"dialoguss.yaml" short:"f" type:"path"`
	Interactive bool   `help:"Interactive mode (similar to running dialoguss run -f ...)"`
	Debug       bool   `help:"Enable debug mode"`
}

type PreviewCmd

type PreviewCmd struct {
	ServerURL string `cmd:"" help:"Server URL for a USSD Studio server" default:"https://ussd-studio-api.nndi.cloud"`
}

func (*PreviewCmd) Run

func (r *PreviewCmd) Run(globals *Globals) error

type RunCmd

type RunCmd struct {
}

func (*RunCmd) Run

func (r *RunCmd) Run(globals *Globals) error

type SimulateCmd

type SimulateCmd struct{}

func (*SimulateCmd) Run

func (simCmd *SimulateCmd) Run(globals *Globals) error

type VersionFlag

type VersionFlag string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL