minid.commandline
This module contains a struct that implements a simple interactive
commandline
for running MiniD code.
License:
Copyright (c) 2008 Jarrett Billingsley
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the
use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software in a
product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Authors:
John Demme (2007, initial code)
Robert Clipsham (2009, added readline support)
- struct
MDConsoleInput
;
- An Input struct to be used with the CLI struct, which wraps standard in/out.
- alias
MDDefaultInput
;
- An alias to the default Input type.
- template
IsValidInputType
(T)
- A template that checks that a given type conforms to the Input interface used by
the CLI struct. The given type T must implement "char[] readln(MDThread* t, char[] p)",
where 't' is a thread object and 'p' is the prompt to be used for getting a line of input. It
may optionally implement a method "init(MDThread* t)", which is called when the interactive
CLI prompt is started and can be used to initialize members. It may optionally implement a
method "cleanup(MDThread* t)", which is called when the interactive CLI prompt is exited and
can be used to clean up resources. If T is a class, it must have a no-argument constructor.
- struct
CLI
(Input);
- This struct encapsulates an interactive MiniD interpreter. MDCL uses this struct to do its
interactive prompt.
This struct installs a signal handler that catches Ctrl+C (SIGINT) signals. It restores
the old signal handler when it exits.
The Input type must be a struct or class type which implements the Input interface as described
in IsValidInputType.
- void
interactive
(MDThread* t);
- This method runs an
interactive
prompt using the Input type that this struct was templated
with.
Params:
MDThread* t |
The thread to use for this CLI. |
- alias
ConsoleCLI
;
- An alias for CLI instantiated with the default Input type. This is a basic console-
based CLI.
|