JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_ConsoleApplication.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
39{
42
44 ArgumentList (int argc, char* argv[]);
45
48
49 ArgumentList (const ArgumentList&) = default;
50 ArgumentList& operator= (const ArgumentList&) = default;
51
52 //==============================================================================
58 struct Argument
59 {
62
66 File resolveAsFile() const;
67
75
83
85 bool isLongOption() const;
86
88 bool isShortOption() const;
89
91 bool isLongOption (const String& optionRoot) const;
92
97
99 bool isShortOption (char shortOptionCharacter) const;
100
102 bool isOption() const;
103
108
113 };
114
115 //==============================================================================
117 int size() const;
118
120 Argument operator[] (int index) const;
121
124
129 bool containsOption (StringRef option) const;
130
137
141 int indexOfOption (StringRef option) const;
142
145
156
163
168
174
179
186
191
198
201
204};
205
206
207//==============================================================================
237{
238 //==============================================================================
269
270 //==============================================================================
272 void addCommand (Command);
273
278
281
287
291 void printCommandList (const ArgumentList&) const;
292
296 void printCommandDetails (const ArgumentList&, const Command&) const;
297
298 //==============================================================================
305 static void fail (String errorMessage, int returnCode = 1);
306
312
313 //==============================================================================
328 bool optionMustBeFirstArg = false) const;
329
333 int findAndRunCommand (int argc, char* argv[]) const;
334
342 const Command* findCommand (const ArgumentList&, bool optionMustBeFirstArg) const;
343
345 const std::vector<Command>& getCommands() const;
346
347private:
348 //==============================================================================
349 std::vector<Command> commands;
350 int commandIfNoOthersRecognised = -1;
351};
352
353} // namespace juce
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:56
Represents a local file or directory.
Definition juce_File.h:45
A special array for holding a list of strings.
A simple class for holding temporary references to a string literal or String.
The JUCE String class!
Definition juce_String.h:53
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
One of the arguments in an ArgumentList.
bool operator!=(StringRef stringToCompare) const
Compares this argument against a string.
File resolveAsExistingFile() const
Resolves this argument as an absolute File, using the current working directory as a base for resolvi...
String text
The original text of this argument.
bool isLongOption() const
Returns true if this argument starts with a double dash.
File resolveAsExistingFolder() const
Resolves a user-supplied folder name into an absolute File, using the current working directory as a ...
bool isShortOption() const
Returns true if this argument starts with a single dash.
File resolveAsFile() const
Resolves this argument as an absolute File, using the current working directory as a base for resolvi...
bool operator==(StringRef stringToCompare) const
Compares this argument against a string.
String getLongOptionValue() const
If this argument is a long option with a value, this returns the value.
bool isOption() const
Returns true if this argument starts with one or more dashes.
Holds a list of command-line arguments, and provides useful methods for searching and operating on th...
File getExistingFileForOptionAndRemove(StringRef option)
Looks for a file argument using getFileForOption() and fails with a suitable error if the file doesn'...
String removeValueForOption(StringRef option)
Looks for a given argument and returns either its assigned value (for long options) or the string tha...
File getExistingFileForOption(StringRef option) const
Looks for a file argument using getFileForOption() and fails with a suitable error if the file doesn'...
bool removeOptionIfFound(StringRef option)
Returns true if the given string matches one of the arguments, and also removes the argument from the...
File getExistingFolderForOption(StringRef option) const
Looks for a filename argument using getFileForOption() and fails with a suitable error if the file is...
int indexOfOption(StringRef option) const
Returns the index of the given string if it matches one of the arguments, or -1 if it doesn't.
String executableName
The name or path of the executable that was invoked, as it was specified on the command-line.
File getFileForOption(StringRef option) const
Looks for the value of argument using getValueForOption() and tries to parse that value as a file.
void failIfOptionIsMissing(StringRef option) const
Throws an error unless the given option is found in the argument list.
Array< Argument > arguments
The list of arguments (not including the name of the executable that was invoked).
bool containsOption(StringRef option) const
Returns true if the given string matches one of the arguments.
void checkMinNumArguments(int expectedMinNumberOfArgs) const
Throws an error unless there are at least the given number of arguments.
String getValueForOption(StringRef option) const
Looks for a given argument and returns either its assigned value (for long options) or the string tha...
Argument operator[](int index) const
Returns one of the arguments.
int size() const
Returns the number of arguments in the list.
File getFileForOptionAndRemove(StringRef option)
Looks for the value of argument using getValueForOption() and tries to parse that value as a file.
File getExistingFolderForOptionAndRemove(StringRef option)
Looks for a filename argument using getFileForOption() and fails with a suitable error if the file is...
Represents a the set of commands that a console app can perform, and provides helper functions for pe...
void printCommandDetails(const ArgumentList &, const Command &) const
Prints out a longer description of a particular command, based on its longDescription member.
int findAndRunCommand(const ArgumentList &, bool optionMustBeFirstArg=false) const
Looks for the first command in the list which matches the given arguments, and tries to invoke it.
void addDefaultCommand(Command)
Adds a command to the list, and marks it as one which is invoked if no other command matches.
String argumentDescription
A description of the command-line arguments needed for this command, which will be printed as part of...
void printCommandList(const ArgumentList &) const
Prints out the list of commands and their short descriptions in a format that's suitable for use as h...
String commandOption
The option string that must appear in the argument list for this command to be invoked.
const Command * findCommand(const ArgumentList &, bool optionMustBeFirstArg) const
Looks for the first command in the list which matches the given arguments.
void addCommand(Command)
Adds a command to the list.
std::function< void(const ArgumentList &)> command
The actual command that should be invoked to perform this action.
static int invokeCatchingFailures(std::function< int()> &&functionToCall)
Invokes a function, catching any fail() calls that it might trigger, and handling them by printing th...
void addHelpCommand(String helpArgument, String helpMessage, bool makeDefaultCommand)
Adds a help command to the list.
void addVersionCommand(String versionArgument, String versionText)
Adds a command that will print the given text in response to the "--version" option.
String shortDescription
A short (one line) description of this command, which can be printed by ConsoleApplication::printComm...
static void fail(String errorMessage, int returnCode=1)
Throws a failure exception to cause a command-line app to terminate.
const std::vector< Command > & getCommands() const
Gives read-only access to the list of registered commands.
String longDescription
A longer description of this command, for use in extended help.
Represents a command that can be executed if its command-line arguments are matched.