dclish

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package dclish A DCL-like command line parser.

From the OpenVMS manual on how to parse a DCL command line.

The following rules apply when entering DCL commands. Refer to Chapter 5 for information about using extended file names in DCL commands.

  • Use any combination of uppercase and lowercase letters. The DCL interpreter translates lowercase letters to uppercase. Uppercase and lowercase characters in parameter and qualifier values are equivalent unless enclosed in quotation marks (" ").
  • Separate the command name from the first parameter with at least one blank space or a tab.
  • Separate each additional parameter from the previous parameter or qualifier with at least one blank space or a tab.
  • Begin each qualifier with a slash (/). The slash serves as a separator and need not be preceded by blank spaces or tabs.
  • If a parameter or qualifier value includes a blank space or a tab, enclose the parameter or qualifier value in quotation marks.
  • You cannot specify null characters (<NUL>) on a DCL command line, even if you enclose the null character in quotation marks.
  • Include no more than 127 elements (parameters, qualifiers, and qualifier values) in each command line.
  • Each element in a command must not exceed 255 characters. The entire command must not exceed 1024 characters after all symbols1 and lexical functions2 are converted to their values.
  • You can abbreviate a command as long as the abbreviated name remains unique among the defined commands on a system. DCL looks only at the first four characters for uniqueness.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrefixMatch

func PrefixMatch(command string, commands []string) (string, error)

PrefixMatch searches for a command in a list of possible commands.

Types

type ActionFunc

type ActionFunc func(*Command) error

ActionFunc is the function that a command runs.

type Command

type Command struct {
	Flags       Flags
	Args        []string
	MaxArgs     int
	MinArgs     int
	Commands    Commands
	Action      ActionFunc
	Completer   CompleterFunc
	Description string
}

Command contains the definition of a command, its flags, subcommands and a completer function for the arguments. The number of args can be limited.

type Commands

type Commands map[string]*Command

Commands is the full list of commands.

func (Commands) ParseAndRun

func (c Commands) ParseAndRun(line string) error

ParseAndRun parses a command line and runs the command.

type Completer

type Completer struct {
	// contains filtered or unexported fields
}

Completer command completer type.

func NewCompleter

func NewCompleter(commands Commands) Completer

NewCompleter creates a new completer.

func (Completer) Do

func (c Completer) Do(line []rune, pos int) ([][]rune, int)

Do return a list of possible completions.

type CompleterFunc

type CompleterFunc func() []string

CompleterFunc is a function to provide completions for arguments for a given command.

type Flag

type Flag struct {
	OptArg      bool
	Value       string
	Default     string
	Description string
	Set         bool
}

Flag is a flag for a command. In the future setting a type would make things a little easier.

type Flags

type Flags map[string]*Flag

Flags is the list of flags.

Source Files

  • completer.go
  • dclish.go

Jump to

Keyboard shortcuts

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