[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Select a startup class from the command line


On Tue, 22 Apr 2025 at 06:04, BB <adamnt42@xxxxxxxxx> wrote:

> Is this possible?
>
> Some programs run different interfaces depending on the "command"
> specified on the command line, notably (or perhaps notoriously) "apt". Such
> as:
>
> 	apt get <params>
> 	apt install <params>
> 	apt this-that-and-the-other <params>
>
> In my case, I'm trying to develop a library to interface to the
> OpenWeatherMap feed. It will have 3 modes of operation (so far):
>
>    - as a library called from a client application, via an exposed
>    interface class "Weather"
>    - as a normal executable to allow the user to setup some configuration
>    data, such as language, API key, etc
>    - as a normal executable that just shows the weather for a location
>    through a small UI
>
> For the latter two then I want to specify which interface to use is a
> similar way to the "apt" command:
>
>    - weather configure
>    - weather [show] <location params>
>    *[show] is optional, if included, the data is just printed on stdout*
>
> Note, this is different from the normal usage of the gb.args component
> where the "options" must come before the "arguments". Here I have a syntax
> of
>
>     weather <command>  <args>  <options>
>
> So for example,
>
>     weather show -67.42137331544458, 164.77271477068862 -l zu
>
> would print the current weather conditions on Sturge Island to stdout in
> the zulu language (should I ever require it 😕).
>
> tia
>
> bruce
>

Not quite sure the exact problem but to answer some questions...

the -s arg sets startup class with gbx3 and gbr3 but you would then need to
use gbr3 prefix on an executable to give the -s arg and not call the
executable directly.


Args can come after params using Args.class  Args.End()
-------------
Dim aRestOfArgs As String[]
Dim bBoolParam As Boolean
Args.Begin()
bBoolParam = Args.Has("b", "bool", "bool param")

aRestOfArgs = Args.End()
-------------

aRestOfArgs[] is now ALL the other remaining args supplied after the ones
processed between Begin and End are removed. these can be examined and
dealt with accordingly.

Does that help?
Respects
BruceS

Follow-Ups:
Re: Select a startup class from the command lineBruce Steers <bsteers4@xxxxxxxxx>
References:
Select a startup class from the command lineBB <adamnt42@xxxxxxxxx>