diff --git a/CHANGELOG.md b/CHANGELOG.md index c1f041c..106043a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,16 @@ # Changelog -Current Version: 1.0-dirty +Current Version: 1.1 -## Unreleased +## [1.1.0] - 2019-04-14 - Dynamically Remove/Disable/Enable commands and submenus (issue #15) - New variadic template method to add commands and menu (makes Add() deprecated) - Optionally delimitate string parameters by " (issue #38) - Explicitly set the names of parameters in help description +- Unit tests - CMake support -- Unit test +- Vcpkg support ## [1.0.0] - 2019-02-16 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4926b40..07ba691 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,9 +29,10 @@ cmake_minimum_required(VERSION 3.8) -project(cli VERSION 1.0 LANGUAGES CXX) +project(cli VERSION 1.1 LANGUAGES CXX) option(CLI_BuildExamples "Build the examples." OFF) +option(CLI_BuildTests "Build the unit tests." OFF) find_package(Boost 1.55 REQUIRED COMPONENTS system) find_package(Threads REQUIRED) diff --git a/README.md b/README.md index 822e2d1..48dc39c 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,11 @@ A cross-platform header only C++14 library for interactive command line interfac * Async interface * Colors +## How to get CLI library + +* From [GitHub](https://github.com/daniele77/cli/releases) +* Using [Vcpkg](https://github.com/Microsoft/vcpkg) + ## Dependencies The library depends on boost asio (to provide telnet server) @@ -47,7 +52,7 @@ and, if you want to specify the installation path: ## Compilation of the examples You can find some examples in the directory "examples". -Each .cpp file corresponds to an executable. You can compile each sample by including +Each .cpp file corresponds to an executable. You can compile each example by including cli and boost header files and linking boost system (and pthread on linux). To compile the examples using cmake, use: @@ -57,7 +62,7 @@ To compile the examples using cmake, use: cmake .. -DCLI_BuildExamples=ON make all -In the directory examples you can also find: +In the same directory you can also find: * a GNU make file (Makefile) * a Windows nmake file (makefile.win) diff --git a/doc/doxy/Doxyfile b/doc/doxy/Doxyfile index 109d3b0..e590254 100644 --- a/doc/doxy/Doxyfile +++ b/doc/doxy/Doxyfile @@ -1,6 +1,6 @@ ################################################################################ # CLI - A simple command line interface. -# Copyright (C) 2016-2019 Daniele Pallastrelli +# Copyright (C) 2019 Daniele Pallastrelli # # Boost Software License - Version 1.0 - August 17th, 2003 # diff --git a/test/makefile.win b/test/makefile.win index 55079e0..c2ad70f 100644 --- a/test/makefile.win +++ b/test/makefile.win @@ -29,13 +29,13 @@ # usage: # set env var BOOST to boost lib path -# nmake /f makefile.win32 +# nmake /f makefile.win # or -# nmake /f makefile.win32 DEBUG=1 +# nmake /f makefile.win DEBUG=1 # or -# nmake /f makefile.win32 UNICODE=1 +# nmake /f makefile.win UNICODE=1 # or -# nmake /f makefile.win32 DEBUG=1 UNICODE=1 +# nmake /f makefile.win DEBUG=1 UNICODE=1 #define macros EXE_NAME = test_suite.exe diff --git a/test/test_history.cpp b/test/test_history.cpp index 55f0907..69c1f8c 100644 --- a/test/test_history.cpp +++ b/test/test_history.cpp @@ -35,24 +35,6 @@ using namespace cli::detail; BOOST_AUTO_TEST_SUITE(HistorySuite) -/* -content -- time_0_cmd -- time_1_cmd -- time_2_cmd -- time_3_cmd -- current_editing - -arrow up goes through: -- current_editing -- time_3_cmd -- time_2_cmd -- time_1_cmd -- time_0_cmd (and stops here) - -arrow down stops at "current_editing" -*/ - BOOST_AUTO_TEST_CASE(NotFull) { History history(10); @@ -63,48 +45,48 @@ BOOST_AUTO_TEST_CASE(NotFull) BOOST_CHECK_EQUAL(history.Previous(""), "item4"); BOOST_CHECK_EQUAL(history.Next(), ""); + BOOST_CHECK_EQUAL(history.Previous(""), "item4"); + BOOST_CHECK_EQUAL(history.Previous("item4"), "item3"); + BOOST_CHECK_EQUAL(history.Previous("item3"), "item2"); + BOOST_CHECK_EQUAL(history.Previous("item2"), "item1"); + BOOST_CHECK_EQUAL(history.Previous("item1"), "item1"); } -#if 0 BOOST_AUTO_TEST_CASE(Full) { History history(3); - history.Add("item1"); - history.Add("item2"); - history.Add("item3"); - history.Add("item4"); + history.NewCommand("item1"); + history.NewCommand("item2"); + history.NewCommand("item3"); + history.NewCommand("item4"); - BOOST_CHECK_EQUAL(history.GetCurrent(), "item4"); - history.ToPreviousEntry(); - BOOST_CHECK_EQUAL(history.GetCurrent(), "item3"); - history.ToNextEntry(); - BOOST_CHECK_EQUAL(history.GetCurrent(), "item4"); - history.ToNextEntry(); - BOOST_CHECK_EQUAL(history.GetCurrent(), "item4"); - history.ToNextEntry(); - BOOST_CHECK_EQUAL(history.GetCurrent(), "item4"); + BOOST_CHECK_EQUAL(history.Previous(""), "item4"); + BOOST_CHECK_EQUAL(history.Next(), ""); + BOOST_CHECK_EQUAL(history.Previous(""), "item4"); + BOOST_CHECK_EQUAL(history.Previous("item4"), "item3"); + BOOST_CHECK_EQUAL(history.Previous("item3"), "item3"); + BOOST_CHECK_EQUAL(history.Previous("item3"), "item3"); + BOOST_CHECK_EQUAL(history.Previous("item3"), "item3"); + BOOST_CHECK_EQUAL(history.Next(), "item4"); + BOOST_CHECK_EQUAL(history.Next(), ""); +} - history.ToPreviousEntry(); - BOOST_CHECK_EQUAL(history.GetCurrent(), "item3"); - history.ToPreviousEntry(); - BOOST_CHECK_EQUAL(history.GetCurrent(), "item2"); - history.ToPreviousEntry(); - BOOST_CHECK_EQUAL(history.GetCurrent(), "item2"); - history.ToPreviousEntry(); - BOOST_CHECK_EQUAL(history.GetCurrent(), "item2"); - history.ToNextEntry(); - BOOST_CHECK_EQUAL(history.GetCurrent(), "item3"); - history.ToNextEntry(); - BOOST_CHECK_EQUAL(history.GetCurrent(), "item4"); - history.ToPreviousEntry(); - BOOST_CHECK_EQUAL(history.GetCurrent(), "item3"); - history.ToPreviousEntry(); - BOOST_CHECK_EQUAL(history.GetCurrent(), "item2"); +BOOST_AUTO_TEST_CASE(Insertion) +{ + History history(10); + history.NewCommand("item1"); + history.NewCommand("item2"); + history.NewCommand("item3"); + history.NewCommand("item4"); - history.ResetCurrent(); - BOOST_CHECK_EQUAL(history.GetCurrent(), "item4"); + BOOST_CHECK_EQUAL(history.Previous(""), "item4"); + BOOST_CHECK_EQUAL(history.Previous("item4"), "item3"); + BOOST_CHECK_EQUAL(history.Previous("foo"), "item2"); + BOOST_CHECK_EQUAL(history.Next(), "foo"); + BOOST_CHECK_EQUAL(history.Next(), "item4"); + BOOST_CHECK_EQUAL(history.Previous("item4"), "foo"); + BOOST_CHECK_EQUAL(history.Previous("foo"), "item2"); } -#endif BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file