From fcebea238423bc6b0f79127fe624e66182280ce7 Mon Sep 17 00:00:00 2001 From: Geert Bevin Date: Fri, 14 Apr 2017 14:47:13 +0200 Subject: [PATCH] Added support for standard Unix --help, -h and --version arguments --- Builds/LinuxMakefile/Makefile | 4 +-- .../receivemidi.xcodeproj/project.pbxproj | 8 +++--- Builds/VisualStudio2015/receivemidi.vcxproj | 4 +-- Builds/VisualStudio2015/resources.rc | 6 ++--- JuceLibraryCode/JuceHeader.h | 4 +-- Source/Main.cpp | 26 ++++++++++++++++--- receivemidi.jucer | 2 +- 7 files changed, 37 insertions(+), 17 deletions(-) diff --git a/Builds/LinuxMakefile/Makefile b/Builds/LinuxMakefile/Makefile index d2b363e..a5049eb 100644 --- a/Builds/LinuxMakefile/Makefile +++ b/Builds/LinuxMakefile/Makefile @@ -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.3 -DJUCE_APP_VERSION_HEX=0x10003 $(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.4 -DJUCE_APP_VERSION_HEX=0x10004 $(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) @@ -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.3 -DJUCE_APP_VERSION_HEX=0x10003 $(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.4 -DJUCE_APP_VERSION_HEX=0x10004 $(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) diff --git a/Builds/MacOSX/receivemidi.xcodeproj/project.pbxproj b/Builds/MacOSX/receivemidi.xcodeproj/project.pbxproj index 8587260..4e724d2 100644 --- a/Builds/MacOSX/receivemidi.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/receivemidi.xcodeproj/project.pbxproj @@ -954,8 +954,8 @@ "_DEBUG=1", "DEBUG=1", "JUCER_XCODE_MAC_F6D2F4CF=1", - "JUCE_APP_VERSION=1.0.3", - "JUCE_APP_VERSION_HEX=0x10003", ); + "JUCE_APP_VERSION=1.0.4", + "JUCE_APP_VERSION_HEX=0x10004", ); GCC_VERSION = com.apple.compilers.llvm.clang.1_0; HEADER_SEARCH_PATHS = ("../../JuceLibraryCode", "../../JuceLibraryCode/modules", "$(inherited)"); INSTALL_PATH = "/usr/bin"; @@ -976,8 +976,8 @@ "_NDEBUG=1", "NDEBUG=1", "JUCER_XCODE_MAC_F6D2F4CF=1", - "JUCE_APP_VERSION=1.0.3", - "JUCE_APP_VERSION_HEX=0x10003", ); + "JUCE_APP_VERSION=1.0.4", + "JUCE_APP_VERSION_HEX=0x10004", ); GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; HEADER_SEARCH_PATHS = ("../../JuceLibraryCode", "../../JuceLibraryCode/modules", "$(inherited)"); diff --git a/Builds/VisualStudio2015/receivemidi.vcxproj b/Builds/VisualStudio2015/receivemidi.vcxproj index 30fece6..f780317 100644 --- a/Builds/VisualStudio2015/receivemidi.vcxproj +++ b/Builds/VisualStudio2015/receivemidi.vcxproj @@ -58,7 +58,7 @@ Disabled EditAndContinue ..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;_CONSOLE;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.0.3;JUCE_APP_VERSION_HEX=0x10003;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;_CONSOLE;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.0.4;JUCE_APP_VERSION_HEX=0x10004;%(PreprocessorDefinitions) MultiThreadedDebug true @@ -99,7 +99,7 @@ Full ..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;_CONSOLE;WIN32;_WINDOWS;NDEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.0.3;JUCE_APP_VERSION_HEX=0x10003;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;_CONSOLE;WIN32;_WINDOWS;NDEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.0.4;JUCE_APP_VERSION_HEX=0x10004;%(PreprocessorDefinitions) MultiThreaded true diff --git a/Builds/VisualStudio2015/resources.rc b/Builds/VisualStudio2015/resources.rc index 6b9c1da..431e261 100644 --- a/Builds/VisualStudio2015/resources.rc +++ b/Builds/VisualStudio2015/resources.rc @@ -7,7 +7,7 @@ #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 1,0,3,0 +FILEVERSION 1,0,4,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -15,9 +15,9 @@ BEGIN BEGIN VALUE "CompanyName", "Uwyn\0" VALUE "FileDescription", "receivemidi\0" - VALUE "FileVersion", "1.0.3\0" + VALUE "FileVersion", "1.0.4\0" VALUE "ProductName", "receivemidi\0" - VALUE "ProductVersion", "1.0.3\0" + VALUE "ProductVersion", "1.0.4\0" END END diff --git a/JuceLibraryCode/JuceHeader.h b/JuceLibraryCode/JuceHeader.h index 2f5fa28..5ec2520 100644 --- a/JuceLibraryCode/JuceHeader.h +++ b/JuceLibraryCode/JuceHeader.h @@ -32,8 +32,8 @@ namespace ProjectInfo { const char* const projectName = "receivemidi"; - const char* const versionString = "1.0.3"; - const int versionNumber = 0x10003; + const char* const versionString = "1.0.4"; + const int versionNumber = 0x10004; } #endif diff --git a/Source/Main.cpp b/Source/Main.cpp index 800d8f8..e285fdf 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp @@ -143,6 +143,19 @@ class receiveMidiApplication : public JUCEApplicationBase, public MidiInputCall 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("--")) @@ -765,10 +778,16 @@ class receiveMidiApplication : public JUCEApplicationBase, public MidiInputCall 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/ReceiveMIDI" << std::endl << std::endl; + std::cout << "https://github.com/gbevin/ReceiveMIDI" << 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_) @@ -785,6 +804,8 @@ class receiveMidiApplication : public JUCEApplicationBase, public MidiInputCall 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; @@ -816,7 +837,6 @@ class receiveMidiApplication : public JUCEApplicationBase, public MidiInputCall << "By setting the octave for middle C, the note name range can be changed. " << std::endl << "Sharps can be added by using the '#' symbol after the note letter, and flats" << std::endl << "by using the letter 'b'. " << std::endl; - std::cout << std::endl; } Array commands_; diff --git a/receivemidi.jucer b/receivemidi.jucer index d9dc07b..44e768d 100644 --- a/receivemidi.jucer +++ b/receivemidi.jucer @@ -1,6 +1,6 @@ -