Class tsysenvmanager

Unit

Declaration

type tsysenvmanager = class(tmsecomponent, istatfile)

Description

Parses and validates the command line arguments (or an explicit array of values) according to a declarative array of argumentdefty records, and prints a usage message if a mandatory argument is missing.

The following example declares a mandatory named argument (-o) and an optional positional argument, then reads back their values with the value property.

uses
  sysutils,
  msesys,
  msesysutils,
  msetypes,
  msesysenv,
  msestrings;

type
  argty = (arg_dest, arg_names);

const
  arguments: array[argty] of argumentdefty = (
    (kind: ak_pararg; name: 'o'; anames: nil; flags: [arf_mandatory]; initvalue: ''),
    (kind: ak_arg;    name: '';  anames: nil; flags: [];              initvalue: '')
  );

var
  sysenv: tsysenvmanager;
  s1, s2: msestring;

begin
  sysenv := tsysenvmanager.create(nil);
  try
    if sysenv.init(arguments) then
    begin
      s1 := sysenv.value[ord(arg_dest)];
      s2 := sysenv.value[ord(arg_names)];
      writestdout('s1 = "' + string(s1) + '"' + lineending);
      writestdout('s2 = "' + string(s2) + '"' + lineending);
    end;
  finally
    sysenv.destroy();
  end;
end.

Hierarchy

Overview

Methods

Protected procedure loaded; override;
Protected procedure defineproperties(filer: tfiler); override;
Protected procedure dostatread(const reader: tstatreader); virtual;
Protected procedure dostatwrite(const writer: tstatwriter); virtual;
Protected procedure statreading;
Protected procedure statread;
Protected function getstatvarname: msestring;
Protected function getstatpriority: integer;
Public constructor create(aowner: tcomponent); override;
Public function init(const arguments: array of argumentdefty; const values: msestringarty): boolean;
Public function init(const arguments: array of argumentdefty): boolean;
Public function init(const values: msestringarty): boolean;
Public function init(): boolean;
Public procedure processinfo(index: integer; value: string);
Public procedure errormessage(const mess: msestring);
Public procedure printmessage(value: msestring);
Public procedure printhelp;
Public function getcommandlinemacros(const macrodef: integer; const firstenvvarmacro: integer = -1; const lastenvvarmacro: integer = -1; prepend: macroinfoarty = nil): macroinfoarty;
Public function getintegervalue(var avalue: integer; const index: integer; const min: integer = minint; const max: integer = maxint): boolean;
Public function findfirstfile(filename: filenamety; searchinvars: array of integer): filenamety;
Public function findlastfile(filename: filenamety; searchinvars: array of integer): filenamety;

Properties

Public property errorcount: int32 read ferrorcount;
Public property defined[index: integer]: boolean read getdefined write setdefined; default;
Public property objectlinker: tobjectlinker read getobjectlinker ;
Public property values[index: integer]: msestringarty read getvalues write setvalues;
Public property value[index: integer]: msestring read getvalue write setvalue;
Public property integervalue[index: integer]: integer read getintegervalue1 write setintegervalue;
Public property defs: sysenvdefarty read fdefs write setdefs;
Public property defcount: int32 read getdefcount;
Published property options: sysenvoptionsty read foptions write setoptions default defaultsysenvmanageroptions;
Published property errorcode: integer read ferrorcode write ferrorcode default defaulterrorcode;
Published property statfile: tstatfile read fstatfile write setstatfile;
Published property statvarname: msestring read getstatvarname write fstatvarname;
Published property statpriority: integer read fstatpriority write fstatpriority default 0;
Published property helpheader: msestring read fhelpheader write fhelpheader;
Published property helpfooter: msestring read fhelpfooter write fhelpfooter;
Published property onvalueread: sysenvmanagervalueeventty read fonvalueread write fonvalueread;
Published property oninit: sysenvmanagereventty read foninit write setoninit;
Published property onafterinit: sysenvmanagereventty read fonafterinit write fonafterinit;

Description

Methods

Protected procedure loaded; override;

This item has no description.

Protected procedure defineproperties(filer: tfiler); override;

This item has no description.

Protected procedure dostatread(const reader: tstatreader); virtual;

This item has no description.

Protected procedure dostatwrite(const writer: tstatwriter); virtual;

This item has no description.

Protected procedure statreading;

This item has no description.

Protected procedure statread;

This item has no description.

Protected function getstatvarname: msestring;

This item has no description.

Protected function getstatpriority: integer;

This item has no description.

Public constructor create(aowner: tcomponent); override;

This item has no description.

Public function init(const arguments: array of argumentdefty; const values: msestringarty): boolean;

This item has no description.

Public function init(const arguments: array of argumentdefty): boolean;

This item has no description.

Public function init(const values: msestringarty): boolean;

This item has no description.

Public function init(): boolean;

This item has no description.

Public procedure processinfo(index: integer; value: string);

This item has no description.

Public procedure errormessage(const mess: msestring);

This item has no description.

Public procedure printmessage(value: msestring);

This item has no description.

Public procedure printhelp;

This item has no description.

Public function getcommandlinemacros(const macrodef: integer; const firstenvvarmacro: integer = -1; const lastenvvarmacro: integer = -1; prepend: macroinfoarty = nil): macroinfoarty;

This item has no description.

Public function getintegervalue(var avalue: integer; const index: integer; const min: integer = minint; const max: integer = maxint): boolean;

This item has no description.

Public function findfirstfile(filename: filenamety; searchinvars: array of integer): filenamety;

This item has no description.

Public function findlastfile(filename: filenamety; searchinvars: array of integer): filenamety;

This item has no description.

Properties

Public property errorcount: int32 read ferrorcount;

This item has no description.

Public property defined[index: integer]: boolean read getdefined write setdefined; default;

This item has no description.

Public property objectlinker: tobjectlinker read getobjectlinker ;

This item has no description.

Public property values[index: integer]: msestringarty read getvalues write setvalues;

This item has no description.

Public property value[index: integer]: msestring read getvalue write setvalue;

This item has no description.

Public property integervalue[index: integer]: integer read getintegervalue1 write setintegervalue;

This item has no description.

Public property defs: sysenvdefarty read fdefs write setdefs;

This item has no description.

Public property defcount: int32 read getdefcount;

This item has no description.

Published property options: sysenvoptionsty read foptions write setoptions default defaultsysenvmanageroptions;

This item has no description.

Published property errorcode: integer read ferrorcode write ferrorcode default defaulterrorcode;

This item has no description.

Published property statfile: tstatfile read fstatfile write setstatfile;

This item has no description.

Published property statvarname: msestring read getstatvarname write fstatvarname;

This item has no description.

Published property statpriority: integer read fstatpriority write fstatpriority default 0;

This item has no description.

Published property helpheader: msestring read fhelpheader write fhelpheader;

This item has no description.

Published property helpfooter: msestring read fhelpfooter write fhelpfooter;

This item has no description.

Published property onvalueread: sysenvmanagervalueeventty read fonvalueread write fonvalueread;

This item has no description.

Published property oninit: sysenvmanagereventty read foninit write setoninit;

This item has no description.

Published property onafterinit: sysenvmanagereventty read fonafterinit write fonafterinit;

This item has no description.


Generated by PasDoc 1.0.4.