YaST2 Developers Documentation: yast2



functions
files
intro

yast2

modules/CommandLine.ycp
Command line interface for YaST2 modules Author: Stanislav Visnovsky

Imports

  • Mode
  • Progress
  • Report
  • RichText
  • RichText
  • String
  • TypeRepository

Global Functions

Local Variables

Local Functions

local systemcommands -> commands_t

Map of commands for every module. ATM the list of commands this module handles internally.

local modulecommands -> map

Map of commands defined by the YaST2 module.

local allcommands -> map

Merged map of commands - both defined by the YaST2 module and system commands. Used for lookup

local interactive -> boolean

User asked for interactive session

local done -> boolean

All commands have been processed

local aborted -> boolean

User asked for quitting of interactive session, or there was an error

global Print (string s) -> void

Print a string to /dev/tty in interactive mode, to stderr in non-interactive Suppress printing if there are no commands to be handled (starting GUI)

Parameters:
s the string to be printed

global Error (string message) -> void

Print an error message and add the description how to get the help.

Parameters:
message error message to be printed. Use nil for no message

global Parse (list<any> arguments) -> map<string, any>

Parse a list of arguments. It checks the validity of the arguments, the type correctness and returns the command and its options in a map.

Parameters:
arguments the list of arguments to be parsed
Return value:
containing the command and it's option. In case of error it is an empty map.

local PrintHead () -> void

Print a nice heading for this module

local PrintActionHelp (string action) -> void

Print a help text for a given action.

Parameters:
action the action for which the help should be printed

local PrintGeneralHelp () -> void

Print a general help - list of available command.

local ProcessSystemCommands (map command) -> boolean

Handle the system-wide commands, like help etc.

Parameters:
command a map of the current command
Return value:
true, if the command was handled

global Init (map cmdlineinfo, list<any> args) -> boolean

Initialize the module, setup the command line syntax and arguments passed on the command line.

Parameters:
cmdlineinfo the map describing the module command line
args arguments given by the user on the command line
Return value:
true, if there are some commands to be processed
See:
Command

global Scan () -> list<string>

Scan a command line from stdin, return it split into a list

Return value:
the list of command line parts, nil for end of file

global Command () -> map

Get next user-given command. If there is a command available, returns it, otherwise ask the user for a command (in interactive mode). Also processes system commands.

Return value:
of the new command. If there is no more commands, it returns exit or quit depending on the result user asked for.
See:
Parse

global StartGUI () -> boolean

Should module start UI?

Return value:
true, if the user asked for standard UI (no parameter was passed by command line)

global Interactive () -> boolean

Is module started in interactive command-line mode?

Return value:
true, if the user asked for interactive command-line mode

global Aborted () -> boolean

User asked for abort (forgetting the changes)

Return value:
true, if the user asked abort

global Abort () -> void

Abort the command line handling

global Done () -> boolean

Are there some commands to be processed?

Return value:
true, if there is no more commands to be processed, either because the user used command line, or the interactive mode was finished

global UniqueOption (map<string, string> options, list unique_options) -> string

Check uniqueness of an option. Simply pass the list of user-specified options and a list of mutually exclusive options. In case of error, Report::Error is used.

Parameters:
options options specified by the user on the command line to be checked
unique_options list of mutually exclusive options to check against
Return value:
nil if there is a problem, otherwise the unique option found

Info:

Function to parse the command line, start a GUI or handle interactive and command line actions as supported by the CommandLine module.

Parameters:
commandline a map used in the CommandLine module with information about the handlers for GUI and commands.
Return value:
true if the changes should be written, false if there was an error or no changes to be written (for example "help").

YaST2 Developers Documentation