Skip to content

Commit

Permalink
Added support for standard Unix --help, -h and --version arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
gbevin committed Apr 14, 2017
1 parent 277961a commit f46ba51
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Builds/LinuxMakefile/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ifeq ($(CONFIG),Debug)
TARGET_ARCH := -march=native
endif

JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DDEBUG=1 -D_DEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=1.0.11 -DJUCE_APP_VERSION_HEX=0x1000b $(shell pkg-config --cflags alsa libcurl x11) -pthread -I../../JuceLibraryCode -I../../JuceLibraryCode/modules $(CPPFLAGS)
JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DDEBUG=1 -D_DEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=1.0.12 -DJUCE_APP_VERSION_HEX=0x1000c $(shell pkg-config --cflags alsa libcurl x11) -pthread -I../../JuceLibraryCode -I../../JuceLibraryCode/modules $(CPPFLAGS)
JUCE_CFLAGS += $(JUCE_CPPFLAGS) $(TARGET_ARCH) -g -ggdb -O0 -mtune=core2 -march=core2 $(CFLAGS)
JUCE_CXXFLAGS += $(JUCE_CFLAGS) -std=c++11 $(CXXFLAGS)
JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) $(shell pkg-config --libs alsa libcurl x11) -ldl -lpthread -lrt $(LDFLAGS)
Expand All @@ -53,7 +53,7 @@ ifeq ($(CONFIG),Release)
TARGET_ARCH :=
endif

JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DNDEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=1.0.11 -DJUCE_APP_VERSION_HEX=0x1000b $(shell pkg-config --cflags alsa libcurl x11) -pthread -I../../JuceLibraryCode -I../../JuceLibraryCode/modules $(CPPFLAGS)
JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DNDEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=1.0.12 -DJUCE_APP_VERSION_HEX=0x1000c $(shell pkg-config --cflags alsa libcurl x11) -pthread -I../../JuceLibraryCode -I../../JuceLibraryCode/modules $(CPPFLAGS)
JUCE_CFLAGS += $(JUCE_CPPFLAGS) $(TARGET_ARCH) -O3 -mtune=core2 -march=core2 $(CFLAGS)
JUCE_CXXFLAGS += $(JUCE_CFLAGS) -std=c++11 $(CXXFLAGS)
JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR) -fvisibility=hidden $(shell pkg-config --libs alsa libcurl x11) -ldl -lpthread -lrt $(LDFLAGS)
Expand Down
8 changes: 4 additions & 4 deletions Builds/MacOSX/sendmidi.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,8 @@
"_DEBUG=1",
"DEBUG=1",
"JUCER_XCODE_MAC_F6D2F4CF=1",
"JUCE_APP_VERSION=1.0.11",
"JUCE_APP_VERSION_HEX=0x1000b", );
"JUCE_APP_VERSION=1.0.12",
"JUCE_APP_VERSION_HEX=0x1000c", );
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = ("../../JuceLibraryCode", "../../JuceLibraryCode/modules", "$(inherited)");
INSTALL_PATH = "/usr/bin";
Expand All @@ -976,8 +976,8 @@
"_NDEBUG=1",
"NDEBUG=1",
"JUCER_XCODE_MAC_F6D2F4CF=1",
"JUCE_APP_VERSION=1.0.11",
"JUCE_APP_VERSION_HEX=0x1000b", );
"JUCE_APP_VERSION=1.0.12",
"JUCE_APP_VERSION_HEX=0x1000c", );
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = ("../../JuceLibraryCode", "../../JuceLibraryCode/modules", "$(inherited)");
Expand Down
6 changes: 3 additions & 3 deletions Builds/VisualStudio2015/resources.rc
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
#include <windows.h>

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,11,0
FILEVERSION 1,0,12,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "Uwyn\0"
VALUE "FileDescription", "sendmidi\0"
VALUE "FileVersion", "1.0.11\0"
VALUE "FileVersion", "1.0.12\0"
VALUE "ProductName", "sendmidi\0"
VALUE "ProductVersion", "1.0.11\0"
VALUE "ProductVersion", "1.0.12\0"
END
END

Expand Down
4 changes: 2 additions & 2 deletions Builds/VisualStudio2015/sendmidi.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<Optimization>Disabled</Optimization>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<AdditionalIncludeDirectories>..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CONSOLE;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.0.11;JUCE_APP_VERSION_HEX=0x1000b;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CONSOLE;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.0.12;JUCE_APP_VERSION_HEX=0x1000c;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
Expand Down Expand Up @@ -99,7 +99,7 @@
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CONSOLE;WIN32;_WINDOWS;NDEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.0.11;JUCE_APP_VERSION_HEX=0x1000b;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CONSOLE;WIN32;_WINDOWS;NDEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.0.12;JUCE_APP_VERSION_HEX=0x1000c;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
Expand Down
4 changes: 2 additions & 2 deletions JuceLibraryCode/JuceHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
namespace ProjectInfo
{
const char* const projectName = "sendmidi";
const char* const versionString = "1.0.11";
const int versionNumber = 0x1000b;
const char* const versionString = "1.0.12";
const int versionNumber = 0x1000c;
}
#endif

Expand Down
27 changes: 23 additions & 4 deletions Source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ class sendMidiApplication : public JUCEApplicationBase
void initialise(const String&) override
{
StringArray cmdLineParams(getCommandLineParameterArray());
if (cmdLineParams.contains("--help") || cmdLineParams.contains("-h"))
{
printUsage();
systemRequestedQuit();
return;
}
else if (cmdLineParams.contains("--version"))
{
printVersion();
systemRequestedQuit();
return;
}

parseParameters(cmdLineParams);

if (cmdLineParams.contains("--"))
Expand Down Expand Up @@ -722,10 +735,16 @@ class sendMidiApplication : public JUCEApplicationBase
return (uint16)jlimit(0, 0x3fff, value);
}

void printUsage()
void printVersion()
{
std::cout << ProjectInfo::projectName << " v" << ProjectInfo::versionString << std::endl;
std::cout << "https://github.com/gbevin/SendMIDI" << std::endl << std::endl;
std::cout << "https://github.com/gbevin/SendMIDI" << std::endl;
}

void printUsage()
{
printVersion();
std::cout << std::endl;
std::cout << "Usage: " << ProjectInfo::projectName << " [ commands ] [ programfile ] [ -- ]" << std::endl << std::endl
<< "Commands:" << std::endl;
for (auto&& cmd : commands_)
Expand All @@ -742,6 +761,8 @@ class sendMidiApplication : public JUCEApplicationBase
std::cout << " " << cmd.commandDescription_;
std::cout << std::endl;
}
std::cout << " -h or --help Print Help (this message) and exit" << std::endl;
std::cout << " --version Print version information and exit" << std::endl;
std::cout << " -- Read commands from standard input until it's closed" << std::endl;
std::cout << std::endl;
std::cout << "Alternatively, you can use the following long versions of the commands:" << std::endl;
Expand Down Expand Up @@ -785,8 +806,6 @@ class sendMidiApplication : public JUCEApplicationBase
<< "+00:00:01.060 will execute the next command one second and 60 milliseconds" << std::endl
<< "later. For convenience, a relative timestamp can also be shortened to +SS.MIL" << std::endl
<< "(for example: +01.060)." << std::endl;

std::cout << std::endl;
}

Array<ApplicationCommand> commands_;
Expand Down
2 changes: 1 addition & 1 deletion sendmidi.jucer
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<JUCERPROJECT id="U5JfXz" name="sendmidi" projectType="consoleapp" version="1.0.11"
<JUCERPROJECT id="U5JfXz" name="sendmidi" projectType="consoleapp" version="1.0.12"
bundleIdentifier="com.uwyn.sendmidi" includeBinaryInAppConfig="1"
jucerVersion="4.3.1" companyName="Uwyn" companyWebsite="http://www.uwyn.com"
companyEmail="[email protected]">
Expand Down

0 comments on commit f46ba51

Please sign in to comment.