cli

package
v0.0.0-...-56dd6b8 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AtCommandResultView = MainView{
	Name: "AtCommandResultView",
	Render: func(m Model) string {
		var resultString string
		for _, l := range m.AtCommandResult {
			resultString += fmt.Sprintf("%s\n", l)
		}
		return resultString
	},
	Action: func(m Model) Model {
		return m
	},
	ItemLength: 0,
}
View Source
var AtCommandView = MainView{
	Name: "AtCommandView",
	Render: func(m Model) string {
		var commandListString string
		for i, command := range at_commands.GetModemInfoCommands() {
			cursor := " "
			if m.Cursor == i {
				cursor = "👉"
			}
			commandListString += fmt.Sprintf("%s %s - %s\n", cursor, command.Command, command.Description)
		}
		return commandListString
	},
	Action: func(m Model) Model {
		command := at_commands.GetModemInfoCommands()[m.Cursor]
		info := command.Run(m.SelectedPort)
		m.AtCommandResult = info
		m.MainView = AtCommandResultView
		return m
	},
	ItemLength: len(at_commands.GetModemInfoCommands()),
}
View Source
var CustomInputView = MainView{
	Name: "CustomInputView",
	Render: func(m Model) string {
		return fmt.Sprintf(
			"Custom AT command: %s\n", m.textInput.View(),
		)
	}, Action: func(m Model) Model {
		command := at_commands.AtCommand{Command: m.textInput.Value()}
		info := command.Run(m.SelectedPort)
		m.AtCommandResult = info
		m.MainView = AtCommandResultView
		m.textInput.Blur()
		return m
	},
}
View Source
var SerialPortView = MainView{
	Name: "SerialPortView",
	Render: func(m Model) string {
		var portListString string
		for i, port := range serial_ports.GetSerialPorts() {
			cursor := " "
			if m.Cursor == i {
				cursor = "👉"
			}
			portListString += fmt.Sprintf("%s %s\n", cursor, port.Name)
		}
		return portListString
	},
	Action: func(m Model) Model {
		m.SelectedPort = serial_ports.GetSerialPorts()[m.Cursor]
		m.MainView = AtCommandView
		m.Cursor = 0
		return m
	},
	ItemLength: len(serial_ports.GetSerialPorts()),
}

Functions

This section is empty.

Types

type MainView

type MainView struct {
	Name       string
	Action     func(Model) Model
	ItemLength int
	Render     func(Model) string
}

type Model

type Model struct {
	Cursor          int
	SelectedPort    serial_ports.SerialPort
	MainView        MainView
	AtCommandResult []string
	// contains filtered or unexported fields
}

func InitialModel

func InitialModel() Model

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() string

Jump to

Keyboard shortcuts

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