]> git.armaanb.net Git - gen-shell.git/commitdiff
started to remove tw specifics
authorArmaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me>
Mon, 26 Oct 2020 17:23:52 +0000 (13:23 -0400)
committerArmaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me>
Mon, 26 Oct 2020 17:23:52 +0000 (13:23 -0400)
18 files changed:
AUTHORS
CMakeLists.txt
COPYING
ChangeLog [deleted file]
INSTALL [deleted file]
LICENSE [deleted file]
NEWS [deleted file]
cmake.h
doc/CMakeLists.txt [deleted file]
doc/man/tasksh.1 [deleted file]
doc/man/tasksh.1.in [deleted file]
src/diag.cpp
src/help.cpp
src/main.cpp
src/prompt.cpp
src/review.cpp [deleted file]
src/review.cpp.bak [new file with mode: 0644]
src/shell.cpp

diff --git a/AUTHORS b/AUTHORS
index 9617ccaa970f1284ef4f807f6f43d49cc622b747..e05dce964ec8c5047eae35148fc2e67dbaed09a0 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,28 +1,30 @@
-The development of tasksh was made possible by the significant contributions of
-the following people:
-
-  Paul Beckingham    (Principal Author)
-  Federico Hernandez (Principal Author)
-  Dirk Deimeke       (Technical Advisor & Evangelist)
-
-The following submitted code, packages or analysis, and deserve special thanks:
-
-  Jörg Krause
-  Ben Boeckel
-  ilove zfs
-  Paul Fenwick
-
-Thanks to the following, who submitted detailed bug reports and excellent
-suggestions:
-
-  Kevin Gunn
-  Fidel Mato
-  David Stahl
-  David Patrick
-  jonbobbly
-  hosaka
-  Lars Kumbier
-  Iain R. Learmonth
-  Eric Hymowitz
-  bjonnh
+Gen-shell is created by Armaan Bhojwani
 
+Tasksh was made by the following people:
+  The development of tasksh was made possible by the significant contributions of
+  the following people:
+  
+    Paul Beckingham    (Principal Author)
+    Federico Hernandez (Principal Author)
+    Dirk Deimeke       (Technical Advisor & Evangelist)
+  
+  The following submitted code, packages or analysis, and deserve special thanks:
+  
+    Jörg Krause
+    Ben Boeckel
+    ilove zfs
+    Paul Fenwick
+  
+  Thanks to the following, who submitted detailed bug reports and excellent
+  suggestions:
+  
+    Kevin Gunn
+    Fidel Mato
+    David Stahl
+    David Patrick
+    jonbobbly
+    hosaka
+    Lars Kumbier
+    Iain R. Learmonth
+    Eric Hymowitz
+    bjonnh
index 205cf7bd2945ca58abb2e99878e97b92da0ee417..01081a809f8a0d896a9ce33e01423c8a31cc1ac4 100644 (file)
@@ -3,10 +3,10 @@ set (CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
 set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
 set (HAVE_CMAKE true)
 
-project (tasksh)
+project (gen-shell)
 include (CXXSniffer)
 
-set (PROJECT_VERSION "1.2.0")
+set (PROJECT_VERSION "0.0.1")
 
 include (CheckFunctionExists)
 include (CheckStructHasMember)
@@ -25,20 +25,14 @@ endif (EXISTS ${CMAKE_SOURCE_DIR}/.git/index)
 
 set (PACKAGE "${PROJECT_NAME}")
 set (VERSION "${PROJECT_VERSION}")
-set (PACKAGE_BUGREPORT "support@taskwarrior.org")
 set (PACKAGE_NAME "${PACKAGE}")
 set (PACKAGE_TARNAME "${PACKAGE}")
 set (PACKAGE_VERSION "${VERSION}")
 set (PACKAGE_STRING "${PACKAGE} ${VERSION}")
 
-if (FREEBSD)
-SET (TASKSH_MAN1DIR man/man1            CACHE STRING "Installation directory for man pages, section 1")
-else (FREEBSD)
-SET (TASKSH_MAN1DIR share/man/man1      CACHE STRING "Installation directory for man pages, section 1")
-endif (FREEBSD)
-SET (TASKSH_DOCDIR  share/doc/tasksh    CACHE STRING "Installation directory for doc files")
-SET (TASKSH_RCDIR "${TASKSH_DOCDIR}/rc" CACHE STRING "Installation directory for configuration files")
-SET (TASKSH_BINDIR  bin                 CACHE STRING "Installation directory for the binary")
+SET (GEN-SHELL_DOCDIR  share/doc/gen-shell CACHE STRING "Installation directory for doc files")
+SET (GEN-SHELL_RCDIR "${GEN-SHELL_DOCDIR}/rc" CACHE STRING "Installation directory for configuration files")
+SET (GEN-SHELL bin                 CACHE STRING "Installation directory for the binary")
 
 # include the readline library finder module
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")
@@ -48,8 +42,8 @@ message ("-- Looking for GNU Readline")
 find_package (Readline REQUIRED)
 if (READLINE_FOUND)
   set (HAVE_READLINE true)
-  set (TASKSH_INCLUDE_DIRS ${TASKSH_INCLUDE_DIRS} ${READLINE_INCLUDE_DIR})
-  set (TASKSH_LIBRARIES    ${TASKSH_LIBRARIES}    ${READLINE_LIBRARIES})
+  set (GEN-SHELL_INCLUDE_DIRS ${GEN-SHELL_INCLUDE_DIRS} ${READLINE_INCLUDE_DIR})
+  set (GEN-SHELL_LIBRARIES    ${GEN-SHELL_LIBRARIES}    ${READLINE_LIBRARIES})
 endif (READLINE_FOUND)
 
 message ("-- Configuring cmake.h")
@@ -65,7 +59,7 @@ endif (EXISTS ${CMAKE_SOURCE_DIR}/test)
 
 set (doc_FILES NEWS ChangeLog INSTALL AUTHORS COPYING)
 foreach (doc_FILE ${doc_FILES})
-  install (FILES ${doc_FILE}  DESTINATION ${TASKSH_DOCDIR})
+  install (FILES ${doc_FILE}  DESTINATION ${GEN-SHELL_DOCDIR})
 endforeach (doc_FILE)
 
 # ---
@@ -74,6 +68,6 @@ set (CPACK_SOURCE_GENERATOR "TGZ")
 set (CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION})
 set (CPACK_SOURCE_IGNORE_FILES  "CMakeCache" "CMakeFiles" "CPackConfig" "CPackSourceConfig"
                                 "_CPack_Packages" "cmake_install" "install_manifest" "Makefile$"
-                                "test" "package-config" "misc/*" "src/tasksh$" "README.md"
+                                "test" "package-config" "misc/*" "src/gen-shell$" "README.md"
                                 "/\\\\.gitignore" "/\\\\.git/" "swp$")
 include (CPack)
diff --git a/COPYING b/COPYING
index 929566210ed8a0406e07b7a4157230658280b37d..c93df9c0fb15b189465c658a788f67fa23e4904f 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -1,6 +1,6 @@
-tasksh - a shell/frontend for the command line task list manager taskwarrior.
+gen-shell - a shell/frontend for the command line task list manager taskwarrior.
 
-Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez.
+Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez, 2020 Armaan Bhojwani
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/ChangeLog b/ChangeLog
deleted file mode 100644 (file)
index 733d5fa..0000000
--- a/ChangeLog
+++ /dev/null
@@ -1,50 +0,0 @@
-1.2.0 (2017-05-10) -
-
-- TS-29   tasksh hangs trying to read task from stdin
-          (thanks to ilove zfs).
-- TS-32   control-d to exit
-          (thanks to Eric Hymowitz, Paul Fenwick).
-- TS-34   Tasksh throw a warning at the end of a review command
-          (thanks to bjonnh).
-- Review report now defaults to 6 days instead of 1 weeķ, which is more
-  convenient for those who review weekly
-          (thanks to Dirk Deimeke).
-
------- current release ---------------------------
-
-1.1.0 (2016-09-06) 464f5ae19f853911e739c2489897aef64345c388
-
-- TD-120  Missing cmakedefine for HAVE_GET_CURRENT_DIR_NAME
-          (Thanks to Jörg Krause, Ben Boeckel).
-- TW-1845 Cygwin build fails, missing get_current_dir_name
-          (thanks to hosaka).
-- TS-11   Autoclear in the Task Shell
-          (thanks to Lars Kumbier).
-- TS-24   add review option (m)odify
-          (thanks to David Patrick).
-- TS-28   Please add a (m)odify feature for review
-          (thanks to Iain R. Learmonth).
-- Implemented 'review' command.
-- Implemented 'diag' command.
-- Added 'review N' option, to specify the number of tasks you would like to
-  review.
-- Integrated libshared.git.
-
------- old releases ------------------------------
-
-1.0.0 (2014-12-21) 5934dfcefac6d037a359bc733a8382e42e32552e
-
-- TS-1    Apostrophe inside tasksh 'log' causes segmentation fault
-          (thanks to David Stahl).
-- TS-2    tasksh segfaults if quotes not closed
-          (thanks to Fidel Mato).
-- TS-5    tasksh segfaults
-          (thanks to David Patrick).
-- TS-13   Quotes included when using task shell
-          (thanks to Kevin Gunn).
-- libreadline support added for line editing and command history.
-
------- start -----------------------------------
-
-Project started 2014-06-08
-
diff --git a/INSTALL b/INSTALL
deleted file mode 100644 (file)
index 95f9120..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,131 +0,0 @@
-Installation Instructions
--------------------------
-
-Please follow the instructions below to build and install tasksh from source.
-
-
-Dependencies
-------------
-
-You will need the CMake build system installed in order to build tasksh from
-source.  Information on cmake can be obtained at http://cmake.org
-
-Additionally, you will need:
-
-  libreadline
-
-
-Basic Installation
-------------------
-
-Briefly, these shell commands will unpack, build and install Tasksh:
-
-  $ tar xzf tasksh-X.Y.Z.tar.gz                   [1]
-  $ cd tasksh-X.Y.Z                               [2]
-  $ cmake -DCMAKE_BUILD_TYPE=release .            [3]
-  $ make                                          [4]
-  $ sudo make install                             [5]
-  $ cd .. ; rm -r tasksh-X.Y.Z                    [6]
-
-These commands are explained below:
-
-  1. Unpacks the source tarball.  This creates the directory tasksh-X.Y.Z,
-     containing all the code.
-
-  2. Change directory to the root of the distribution.
-
-  3. Invokes CMake to scan for dependencies and machine-specific details, then
-     generate the makefiles.  Requests an optimized build, which will run faster
-     and be more compact.  This may take a minute.
-
-  4. Builds tasksh.  This may take a minute.
-
-  5. Installs the program, documentation and other data files.
-
-  6. Removes the temporary directory.
-
-
-Build and configurations options
---------------------------------
-
-You can customize the configuration run with cmake variables. This will modify
-the installation process:
-
-To change the installation directory you use the following configuration
-variable:
-
-  $ cmake -DCMAKE_INSTALL_PREFIX=<path-to-installation-dir> .
-
-cmake configuration variables are applied with the -D option and consist of a
-<name> and a <value>:
-
-  $ cmake -D<name>=<value> .
-
-Four more variables can customize the installation process. The following table
-lists them and their defaults plus the CMAKE_INSTALL_PREFIX:
-
-  CMAKE_INSTALL_PREFIX  /usr/local
-  TASKSH_BINDIR         bin
-  TASKSH_DOCDIR         share/doc/tasksh
-  TASKSH_MAN1DIR        share/man/man1
-
-The corresponding TASKSH_* variables will be combined with CMAKE_INSTALL_PREFIX to
-get absolute installation directories:
-
-  CMAKE_INSTALL_PREFIX/TASKSH_BINDIR   /usr/local/bin
-  CMAKE_INSTALL_PREFIX/TASKSH_DOCDIR   /usr/local/share/doc/tasksh
-  CMAKE_INSTALL_PREFIX/TASKSH_MAN1DIR  /usr/local/share/man/man1
-
-
-Uninstallation
---------------
-
-There is no uninstall option in CMake makefiles. This is a manual process.
-
-To uninstall Tasksh, remove the files listed in the install_manifest.txt file
-that was generated when you built Tasksh.
-
-
-Tasksh Build Notes
------------------------
-
-Tasksh has dependencies that are detected by CMake in almost all cases, but
-there are situations and operating systems that mean you will need to offer a
-little help.
-
-If Tasksh will not build on your system, first take a look at the Operating
-System notes below.  If this doesn't help, then go to the Troubleshooting
-section, which includes instructions on how to contact us for help.
-
-
-Operating System Notes
-----------------------
-
-Cygwin
-  If 'make install' fails when writing to the /usr/local/share/ directory,
-  this may be because your current login doesn't have permission to write
-  to the Windows directory containing your Cygwin installation. Either
-  login to Windows as an Administrator and try the 'make install' process
-  again, or reinstall Cygwin under your normal Windows login.
-
-
-Troubleshooting
----------------
-
-If you've recently made changes to dependencies (by reinstalling them, for
-example) be sure to rerun 'cmake .' before trying to execute 'make' again.
-
-CMake will run and locate all the necessary pieces for the build, and create
-a Makefile.  There may be errors and warnings when running CMake, or there
-may be compiler errors and warnings when running 'make'.  Sometimes you will run
-CMake with no reported problems, and the build will fail later.  This is
-almost always because CMake is mistaken about some assumption.
-
-If a build does not succeed, please send the contents of the 'CMakeCache.txt'
-and 'CMakeFiles/CMakeOutput.log' files to support@taskwarrior.org.
-
-If CMake runs but tasksh does not build, please send the contents of the above
-files as well as a transcript from the build, which is not written to a file
-and must be captured from the terminal.
-
----
diff --git a/LICENSE b/LICENSE
deleted file mode 100644 (file)
index f9ab300..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,23 +0,0 @@
-tasksh - a shell/frontend for ithe command line task list manager taskwarrior.
-
-Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
-http://www.opensource.org/licenses/mit-license.php
diff --git a/NEWS b/NEWS
deleted file mode 100644 (file)
index 4f9546e..0000000
--- a/NEWS
+++ /dev/null
@@ -1,43 +0,0 @@
-
-New Features in tasksh 1.2.0
-
-  - Responds to Ctrl-D by exiting.
-
-New commands in tasksh 1.2.0
-
-  - 
-
-New configuration options in tasksh 1.2.0
-
-  - 
-
-Known Issues
-
-  - 
-
-Tasksh has been built and tested on the following configurations:
-
-  * macOS
-  * Fedora
-  * Ubuntu
-  * Debian
-  * Arch
-  * FreeBSD
-  * Cygwin
-
----
-
-While Tasksh has undergone testing, bugs are sure to remain.  If you
-encounter a bug, please enter a new issue at:
-
-  http://bug.tasktools.org
-
-Or you can also report the issue in the forums at:
-
-  http://answers.tasktools.org
-
-Or just send a message to:
-
-  support@taskwarrior.org
-
-Thank you.
diff --git a/cmake.h b/cmake.h
index 6a8947be9aba38350ecd8b25b3b9b4836e7c77f4..5b19e6cbb9c8fdea9f9131a26774921c036799be 100644 (file)
--- a/cmake.h
+++ b/cmake.h
@@ -4,13 +4,12 @@
 #define PRODUCT_TASKSH 1
 
 /* Package information */
-#define PACKAGE           "tasksh"
-#define VERSION           "1.2.0"
-#define PACKAGE_BUGREPORT "support@taskwarrior.org"
-#define PACKAGE_NAME      "tasksh"
-#define PACKAGE_TARNAME   "tasksh"
-#define PACKAGE_VERSION   "1.2.0"
-#define PACKAGE_STRING    "tasksh 1.2.0"
+#define PACKAGE           "gen-shell"
+#define VERSION           "0.0.1"
+#define PACKAGE_NAME      "gen-shell"
+#define PACKAGE_TARNAME   "gen-shell"
+#define PACKAGE_VERSION   "0.0.1"
+#define PACKAGE_STRING    "gen-shell 0.0.1"
 
 #define CMAKE_BUILD_TYPE  ""
 
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
deleted file mode 100644 (file)
index 180543d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-cmake_minimum_required (VERSION 2.8)
-message ("-- Configuring man pages")
-set (man_FILES tasksh.1)
-foreach (man_FILE ${man_FILES})
-  configure_file (
-    man/${man_FILE}.in
-    man/${man_FILE})
-endforeach (man_FILE)
-
-install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man/   DESTINATION ${TASKSH_MAN1DIR}
-                                                      FILES_MATCHING PATTERN "*.1")
-
diff --git a/doc/man/tasksh.1 b/doc/man/tasksh.1
deleted file mode 100644 (file)
index ec53447..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-.TH tasksh 1 2017-05-10 "tasksh 1.2.0" "User Manuals"
-
-.SH NAME
-tasksh \- Interactive taskwarrior shell
-
-.SH SYNOPSIS
-.B tasksh
-.br
-.B tasksh --version
-
-.SH DESCRIPTION
-Tasksh can be used to create a more immersive taskwarrior environment.
-Any task command you run outside the shell can also be run inside
-the shell, without the need to prefix every command with "task".
-
-When built with libreadline, tasksh provides command editing and history.
-
-Tasksh has an integrated 'review' command that leads you through an interactive
-review session.
-
-Tasksh supports all recent versions of Taskwarrior.
-
-.SH COMMANDS
-Tasksh supports the following commands.  All other commands are passed intact to
-Taskwarrior.
-
-.TP
-.B diagnostics
-Displays settings pertinent to tasksh, for diagnosing problems.
-
-.TP
-.B exec <commands>
-This command allows you to run shell commands from within Tasksh. This is ideal
-for accessing man pages such as this. The '!' command can be used in place of
-the 'exec' keyword. Once the command is run, control returns to Tasksh.
-
-.TP
-.B exit/quit
-These commands cause tasksh to terminate, returning you to your system shell.
-
-.TP
-.B help
-Shows a summary of commands, and how to obtain help.
-
-.TP
-.B review [N]
-Begins an interactive review session, where you can mark tasks as reviewed,
-edit them using your text editor, provide modification commands, or skip them.
-You can terminate a review session at any time, and the next review session
-will resume at the right place.
-
-To find tasks needing review, the '_reviewed' custom report is created and run,
-which filters tasks that have a missing 'reviewed' UDA date, or have not been
-reviewed for a week.
-
-This means that if you run a review session to completion, there will be no
-need to review again for a week, and the review command will simply do nothing
-until then.
-
-The one week review cycle is defined by the '_reviewed' custom report, which
-can be modified if you prefer a monthly review cycle.
-
-If 'N' is provided, the session is limited to reviewing only N tasks.
-
-Note: requires Taskwarrior 2.5.0 or later.
-For full details, see: 
-<https://taskwarrior.org/docs/review.html>
-
-.SH USAGE
-Here is an example tasksh session.
-
-$ tasksh
-.br
-task> projects
-.br
-
-.br
-Project Tasks Pri:None Pri:L Pri:M Pri:H
-.br
-------- ----- -------- ----- ----- -----
-.br
-            7        7     0     0     0
-.br
-home        2        2     0     0     0
-.br
-party       6        3     0     0     3
-.br
-
-.br
-3 projects (15 tasks)
-.br
-task> tags
-.br
-
-.br
-Tag  Count
-.br
-mall     2
-.br
-
-.br
-1 tag (15 tasks)
-.br
-task> list
-.br
-
-.br
-ID Project Pri Due        Active Age   Description
-.br
----------------------------------------------------------------------
-.br
- 2 party   H   10/17/2015        2 hrs Select and book a venue
-.br
- 5 party   H   10/22/2015        2 hrs Design invitations
-.br
- 9 home        10/31/2015         1 hr Pay rent
-.br
- 3 party                         2 hrs Mail invitations
-.br
- 4 party                         2 hrs Select a caterer
-.br
- 6 party                         2 hrs Print invitations
-.br
-
-.br
- 8 tasks
-.br
- task> quit
-.br
- $
-.br
-
-.SH CONFIGURATION
-Tasksh piggybacks on Taskwarrior's .taskrc configuration file, and refers
-to settings there. If you use a non-standard location for your .task database
-, and .taskrc file, Tasksh will not find them unless you set the TASKDATA and
-TASKRC environment variables. See 'man taskrc' for more details.
-
-The review command storeѕ a UDA ('reviewed') and report definition ('_reviewed').
-
-.TP
-.B tasksh.autoclear=1
-If set to "1", causes each tasksh command to be preceded by a 'clear screen' and
-cursor reset. Default is "0".
-
-.SH "CREDITS & COPYRIGHTS"
-Copyright (C) 2006 \- 2017 P. Beckingham, F. Hernandez.
-
-This man page was originally written by Federico Hernandez.
-
-Tasksh is distributed under the MIT license. See
-http://www.opensource.org/licenses/mit-license.php for more information.
-
-.SH SEE ALSO
-.BR task(1),
-
-For more information regarding tasksh, see the following:
-
-.TP
-The official site at
-<http://taskwarrior.org/tools>
-
-.TP
-The official code repository at
-<https://git.tasktools.org/scm/ex/tasksh.git>
-
-.TP
-You can contact the project by emailing
-<support@tasktools.org>
-
-.SH REPORTING BUGS
-.TP
-Bugs in tasksh may be reported to the issue-tracker at
-<http://bug.tasktools.org>
-
diff --git a/doc/man/tasksh.1.in b/doc/man/tasksh.1.in
deleted file mode 100644 (file)
index 0b0354c..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-.TH tasksh 1 2017-05-10 "${PACKAGE_STRING}" "User Manuals"
-
-.SH NAME
-tasksh \- Interactive taskwarrior shell
-
-.SH SYNOPSIS
-.B tasksh
-.br
-.B tasksh --version
-
-.SH DESCRIPTION
-Tasksh can be used to create a more immersive taskwarrior environment.
-Any task command you run outside the shell can also be run inside
-the shell, without the need to prefix every command with "task".
-
-When built with libreadline, tasksh provides command editing and history.
-
-Tasksh has an integrated 'review' command that leads you through an interactive
-review session.
-
-Tasksh supports all recent versions of Taskwarrior.
-
-.SH COMMANDS
-Tasksh supports the following commands.  All other commands are passed intact to
-Taskwarrior.
-
-.TP
-.B diagnostics
-Displays settings pertinent to tasksh, for diagnosing problems.
-
-.TP
-.B exec <commands>
-This command allows you to run shell commands from within Tasksh. This is ideal
-for accessing man pages such as this. The '!' command can be used in place of
-the 'exec' keyword. Once the command is run, control returns to Tasksh.
-
-.TP
-.B exit/quit
-These commands cause tasksh to terminate, returning you to your system shell.
-
-.TP
-.B help
-Shows a summary of commands, and how to obtain help.
-
-.TP
-.B review [N]
-Begins an interactive review session, where you can mark tasks as reviewed,
-edit them using your text editor, provide modification commands, or skip them.
-You can terminate a review session at any time, and the next review session
-will resume at the right place.
-
-To find tasks needing review, the '_reviewed' custom report is created and run,
-which filters tasks that have a missing 'reviewed' UDA date, or have not been
-reviewed for a week.
-
-This means that if you run a review session to completion, there will be no
-need to review again for a week, and the review command will simply do nothing
-until then.
-
-The one week review cycle is defined by the '_reviewed' custom report, which
-can be modified if you prefer a monthly review cycle.
-
-If 'N' is provided, the session is limited to reviewing only N tasks.
-
-Note: requires Taskwarrior 2.5.0 or later.
-For full details, see: 
-<https://taskwarrior.org/docs/review.html>
-
-.SH USAGE
-Here is an example tasksh session.
-
-$ tasksh
-.br
-task> projects
-.br
-
-.br
-Project Tasks Pri:None Pri:L Pri:M Pri:H
-.br
-------- ----- -------- ----- ----- -----
-.br
-            7        7     0     0     0
-.br
-home        2        2     0     0     0
-.br
-party       6        3     0     0     3
-.br
-
-.br
-3 projects (15 tasks)
-.br
-task> tags
-.br
-
-.br
-Tag  Count
-.br
-mall     2
-.br
-
-.br
-1 tag (15 tasks)
-.br
-task> list
-.br
-
-.br
-ID Project Pri Due        Active Age   Description
-.br
----------------------------------------------------------------------
-.br
- 2 party   H   10/17/2015        2 hrs Select and book a venue
-.br
- 5 party   H   10/22/2015        2 hrs Design invitations
-.br
- 9 home        10/31/2015         1 hr Pay rent
-.br
- 3 party                         2 hrs Mail invitations
-.br
- 4 party                         2 hrs Select a caterer
-.br
- 6 party                         2 hrs Print invitations
-.br
-
-.br
- 8 tasks
-.br
- task> quit
-.br
- $
-.br
-
-.SH CONFIGURATION
-Tasksh piggybacks on Taskwarrior's .taskrc configuration file, and refers
-to settings there. If you use a non-standard location for your .task database
-, and .taskrc file, Tasksh will not find them unless you set the TASKDATA and
-TASKRC environment variables. See 'man taskrc' for more details.
-
-The review command storeѕ a UDA ('reviewed') and report definition ('_reviewed').
-
-.TP
-.B tasksh.autoclear=1
-If set to "1", causes each tasksh command to be preceded by a 'clear screen' and
-cursor reset. Default is "0".
-
-.SH "CREDITS & COPYRIGHTS"
-Copyright (C) 2006 \- 2017 P. Beckingham, F. Hernandez.
-
-This man page was originally written by Federico Hernandez.
-
-Tasksh is distributed under the MIT license. See
-http://www.opensource.org/licenses/mit-license.php for more information.
-
-.SH SEE ALSO
-.BR task(1),
-
-For more information regarding tasksh, see the following:
-
-.TP
-The official site at
-<http://taskwarrior.org/tools>
-
-.TP
-The official code repository at
-<https://git.tasktools.org/scm/ex/tasksh.git>
-
-.TP
-You can contact the project by emailing
-<support@tasktools.org>
-
-.SH REPORTING BUGS
-.TP
-Bugs in tasksh may be reported to the issue-tracker at
-<http://bug.tasktools.org>
-
index 8478fba2ad658fc3efdb7823d8526893c14b578b..3b4e3a9cdc436db97144325df623333f1df95319 100644 (file)
@@ -1,6 +1,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 //
-// Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez.
+// Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez, 2020 Armaan Bhojwani.
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
index 2af1a01e622883c5b2195d055a72c2535016ec86..6571ce2284bd907f5d46bc5ed26ebb27b8929c34 100644 (file)
@@ -1,6 +1,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 //
-// Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez.
+// Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez, 2020 Armaan Bhojwani.
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
 int cmdHelp ()
 {
   std::cout << '\n'
-            << "  Commands:\n"
-            << "    tasksh> list             Or any other Taskwarrior command\n"
-            << "    tasksh> review [N]       Task review session, with optional cutoff after N tasks\n"
-            << "    tasksh> exec ls -al      Any shell command.  May also use '!ls -al'\n"
-            << "    tasksh> help             Tasksh help\n"
-            << "    tasksh> diagnostics      Tasksh diagnostics\n"
-            << "    tasksh> quit             End of session. May also use 'exit'\n"
-            << '\n'
-            << "Run 'man tasksh' from your shell prompt.\n"
-            << "Run '! man tasksh' from inside tasksh.\n"
-            << '\n';
+            << "A generic shell"
   return 0;
 }
 
index afba7277ec511044acd58b0b19a9f0e3209dbd68..269d7394fe5868a86770ae7c9b7a53ac9b8c43f9 100644 (file)
@@ -1,6 +1,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 //
-// Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez.
+// Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez, 2020 Armaan Bhojwani
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
 #include <readline/history.h>
 #endif
 
-// TODO These conflict with tw commands. This needs to be resolved.
-//      Perhaps an escape, such as '-- help' could invoke local help, or using
-//      a 'task' prefix could disambiguate.
-
 // tasksh commands.
 int cmdHelp ();
 int cmdDiagnostics ();
index b1d40f52e44e1801c65034a18e97aabbb6c99658..3eb12b2fcc4dfe5510403ed4246934553e76e7a6 100644 (file)
@@ -1,6 +1,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 //
-// Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez.
+// Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez, 2020 Armaan Bhojwani
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -88,11 +88,6 @@ std::string composeContexts (bool pretty /* = false */)
 ////////////////////////////////////////////////////////////////////////////////
 std::string promptCompose ()
 {
-  // TODO The prompt may be composed of different elements:
-  // TODO - The configurable text
-  // TODO - The accumulated context, as colored tokens.
-  // TODO - sync status
-  // TODO - time
   auto decoration = composeContexts (true);
   if (decoration.length ())
     return "task " + decoration + "> ";
diff --git a/src/review.cpp b/src/review.cpp
deleted file mode 100644 (file)
index 86ca12f..0000000
+++ /dev/null
@@ -1,320 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-//
-// http://www.opensource.org/licenses/mit-license.php
-//
-////////////////////////////////////////////////////////////////////////////////
-
-#include <cmake.h>
-#include <iostream>
-#include <sstream>
-#include <vector>
-#include <string>
-#include <algorithm>
-#include <stdlib.h>
-
-#ifdef HAVE_READLINE
-#include <readline/readline.h>
-#include <readline/history.h>
-#endif
-
-#include <unistd.h>
-#include <sys/ioctl.h>
-
-#ifdef SOLARIS
-#include <sys/termios.h>
-#endif
-
-#include <Color.h>
-#include <Lexer.h>
-#include <shared.h>
-#include <format.h>
-
-std::string getResponse (const std::string&);
-
-////////////////////////////////////////////////////////////////////////////////
-static unsigned int getWidth ()
-{
-  // Determine window size.
-//  int width = config.getInteger ("defaultwidth");
-  static auto width = 0;
-
-  if (width == 0)
-  {
-    unsigned short buff[4];
-    if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &buff) != -1)
-      width = buff[1];
-  }
-
-  return width;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-static void editTask (const std::string& uuid)
-{
-  std::string command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " edit";
-  system (command.c_str ());
-
-  command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " modify reviewed:now";
-  system (command.c_str ());
-  std::cout << "Modified.\n\n\n\n";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-static void modifyTask (const std::string& uuid)
-{
-  Color text ("color15 on gray6");
-  std::string modifications;
-  do
-  {
-    modifications = getResponse (text.colorize (" Enter modification args [example: +tag -tag /teh/the/ project:X] ") + " ");
-  }
-  while (modifications == "");
-
-  std::string command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " modify " + modifications;
-  system (command.c_str ());
-
-  std::cout << "Modified.\n\n\n\n";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-static void reviewTask (const std::string& uuid)
-{
-  std::string command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " modify reviewed:now";
-  system (command.c_str ());
-  std::cout << "Marked as reviewed.\n\n\n\n";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-static void completeTask (const std::string& uuid)
-{
-  std::string command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " done";
-  system (command.c_str ());
-  std::cout << "Completed.\n\n\n\n";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-static void deleteTask (const std::string& uuid)
-{
-  std::string command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " delete";
-  system (command.c_str ());
-  std::cout << "Deleted.\n\n\n\n";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-static const std::string reviewNothing ()
-{
-  return "\nThere are no tasks needing review.\n\n";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-static const std::string reviewStart (
-  unsigned int width)
-{
-  std::string welcome = "The review process is important for keeping your list "
-                        "accurate, so you are working on the right tasks.\n"
-                        "\n"
-                        "For each task you are shown, look at the metadata. "
-                        "Determine whether the task needs to be changed (enter "
-                        "'e' to edit), or whether it is accurate ('enter' or "
-                        "'r' to mark as reviewed). You may skip a task ('s') "
-                        "but a skipped task is not considered reviewed.\n"
-                        "\n"
-                        "You may stop at any time, and resume later right "
-                        "where you left off. See 'man tasksh' for more details.";
-
-  std::vector <std::string> lines;
-  wrapText (lines, welcome, width, false);
-  welcome = join ("\n", lines);
-
-  return "\n" + welcome + "\n\n";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-static const std::string banner (
-  unsigned int current,
-  unsigned int total,
-  unsigned int width,
-  const std::string& message)
-{
-  std::stringstream progress;
-  progress << " ["
-           << current
-           << " of "
-           << total
-           << "] ";
-
-  Color progressColor ("color15 on color9");
-  Color descColor     ("color15 on gray6");
-
-  std::string composed;
-  if (progress.str ().length () + message.length () + 1 < width)
-    composed = progressColor.colorize (progress.str ()) +
-               descColor.colorize (" " + message +
-                 std::string (width - progress.str ().length () - message.length () - 1, ' '));
-  else
-    composed = progressColor.colorize (progress.str ()) +
-               descColor.colorize (" " + message.substr (0, message.length () - 3) + "...");
-
-  return composed + "\n";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-static const std::string menu ()
-{
-  return Color ("color15 on gray6").colorize (" (Enter) Mark as reviewed, (s)kip, (e)dit, (m)odify, (c)omplete, (d)elete, (q)uit ") + " ";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-static void reviewLoop (const std::vector <std::string>& uuids, unsigned int limit, bool autoClear)
-{
-  auto width = getWidth ();
-  unsigned int reviewed = 0;
-
-  // If a limit was specified ('review 10'), then it should override the data
-  // set size, if it is smaller.
-  unsigned int total = uuids.size ();
-  if (limit)
-    total = std::min (total, limit);
-
-  if (total == 0)
-  {
-    std::cout << reviewNothing ();
-    return;
-  }
-
-  std::cout << reviewStart (width);
-
-  unsigned int current = 0;
-  while (current < total &&
-         (limit == 0 || reviewed < limit))
-  {
-    // Run 'info' report for task.
-    auto uuid = uuids[current];
-
-    // Display banner for this task.
-    std::string dummy;
-    std::string description;
-    execute ("task",
-             {"_get", uuid + ".description"},
-             dummy,
-             description);
-
-    std::string response;
-    bool repeat;
-    do
-    {
-      repeat = false;
-      std::cout << banner (current + 1, total, width, Lexer::trimRight (description, "\n"));
-
-      // Use 'system' to run the command and show the output.
-      std::string command = "task " + uuid + " information";
-      system (command.c_str ());
-
-      // Display prompt, get input.
-      response = getResponse (menu ());
-
-           if (response == "e") { editTask (uuid);                                   }
-      else if (response == "m") { modifyTask (uuid);          repeat = true;         }
-      else if (response == "s") { std::cout << "Skipped\n\n"; ++current;             }
-      else if (response == "c") { completeTask (uuid);        ++current; ++reviewed; }
-      else if (response == "d") { deleteTask (uuid);          ++current; ++reviewed; }
-      else if (response == "")  { reviewTask (uuid);          ++current; ++reviewed; }
-      else if (response == "r") { reviewTask (uuid);          ++current; ++reviewed; }
-      else if (response == "q") { break;                                             }
-
-      else
-      {
-        std::cout << format ("Command '{1}' is not recognized.", response) << "\n";
-      }
-
-      // Note that just hitting <Enter> yields an empty command, which does
-      // nothing but advance to the next task.
-
-      if (autoClear)
-        std::cout << "\033[2J\033[0;0H";
-    }
-    while (repeat);
-
-    if (response == "q")
-      break;
-  }
-
-  std::cout << "\n"
-            << format ("End of review. {1} out of {2} tasks reviewed.", reviewed, total)
-            << "\n\n";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-int cmdReview (const std::vector <std::string>& args, bool autoClear)
-{
-  // Is there a specified limit?
-  unsigned int limit = 0;
-  if (args.size () == 2)
-    limit = strtol (args[1].c_str (), NULL, 10);
-
-  // Configure 'reviewed' UDA, but only if necessary.
-  std::string input;
-  std::string output;
-  auto status = execute ("task", {"_get", "rc.uda.reviewed.type"}, input, output);
-  if (status || output != "date\n")
-  {
-    if (confirm ("Tasksh needs to define a 'reviewed' UDA of type 'date' for all tasks.  Ok to proceed?"))
-    {
-      execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "uda.reviewed.type",  "date"},     input, output);
-      execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "uda.reviewed.label", "Reviewed"}, input, output);
-    }
-  }
-
-  // Configure '_reviewed' report, but only if necessary.
-  status = execute ("task", {"_get", "rc.report._reviewed.columns"}, input, output);
-  if (status || output != "uuid\n")
-  {
-    if (confirm ("Tasksh needs to define a '_reviewed' report to identify tasks needing review.  Ok to proceed?"))
-    {
-      execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "report._reviewed.description",
-                        "Tasksh review report.  Adjust the filter to your needs."                                              }, input, output);
-      execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "report._reviewed.columns", "uuid"               }, input, output);
-      execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "report._reviewed.sort",    "reviewed+,modified+"}, input, output);
-      execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "report._reviewed.filter",
-                        "( reviewed.none: or reviewed.before:now-6days ) and ( +PENDING or +WAITING )"                         }, input, output);
-    }
-  }
-
-  // Obtain a list of UUIDs to review.
-  status = execute ("task",
-                    {
-                      "rc.color=off",
-                      "rc.detection=off",
-                      "rc._forcecolor=off",
-                      "rc.verbose=nothing",
-                      "_reviewed"
-                    },
-                    input, output);
-
-  // Review the set of UUIDs.
-  auto uuids = split (Lexer::trimRight (output, "\n"), '\n');
-  reviewLoop (uuids, limit, autoClear);
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////
diff --git a/src/review.cpp.bak b/src/review.cpp.bak
new file mode 100644 (file)
index 0000000..c74dcfa
--- /dev/null
@@ -0,0 +1,320 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+//
+// http://www.opensource.org/licenses/mit-license.php
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#include <cmake.h>
+#include <iostream>
+#include <sstream>
+#include <vector>
+#include <string>
+#include <algorithm>
+#include <stdlib.h>
+
+#ifdef HAVE_READLINE
+#include <readline/readline.h>
+#include <readline/history.h>
+#endif
+
+#include <unistd.h>
+#include <sys/ioctl.h>
+
+#ifdef SOLARIS
+#include <sys/termios.h>
+#endif
+
+#include <Color.h>
+#include <Lexer.h>
+#include <shared.h>
+#include <format.h>
+
+std::string getResponse (const std::string&);
+
+////////////////////////////////////////////////////////////////////////////////
+static unsigned int getWidth ()
+{
+  // Determine window size.
+//  int width = config.getInteger ("defaultwidth");
+  static auto width = 0;
+
+  if (width == 0)
+  {
+    unsigned short buff[4];
+    if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &buff) != -1)
+      width = buff[1];
+  }
+
+  return width;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+static void editTask (const std::string& uuid)
+{
+  std::string command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " edit";
+  system (command.c_str ());
+
+  command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " modify reviewed:now";
+  system (command.c_str ());
+  std::cout << "Modified.\n\n\n\n";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+static void modifyTask (const std::string& uuid)
+{
+  Color text ("color15 on gray6");
+  std::string modifications;
+  do
+  {
+    modifications = getResponse (text.colorize (" Enter modification args [example: +tag -tag /teh/the/ project:X] ") + " ");
+  }
+  while (modifications == "");
+
+  std::string command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " modify " + modifications;
+  system (command.c_str ());
+
+  std::cout << "Modified.\n\n\n\n";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+static void reviewTask (const std::string& uuid)
+{
+  std::string command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " modify reviewed:now";
+  system (command.c_str ());
+  std::cout << "Marked as reviewed.\n\n\n\n";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+static void completeTask (const std::string& uuid)
+{
+  std::string command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " done";
+  system (command.c_str ());
+  std::cout << "Completed.\n\n\n\n";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+static void deleteTask (const std::string& uuid)
+{
+  std::string command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " delete";
+  system (command.c_str ());
+  std::cout << "Deleted.\n\n\n\n";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+static const std::string reviewNothing ()
+{
+  return "\nThere are no tasks needing review.\n\n";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+static const std::string reviewStart (
+  unsigned int width)
+{
+  std::string welcome = "The review process is important for keeping your list "
+                        "accurate, so you are working on the right tasks.\n"
+                        "\n"
+                        "For each task you are shown, look at the metadata. "
+                        "Determine whether the task needs to be changed (enter "
+                        "'e' to edit), or whether it is accurate ('enter' or "
+                        "'r' to mark as reviewed). You may skip a task ('s') "
+                        "but a skipped task is not considered reviewed.\n"
+                        "\n"
+                        "You may stop at any time, and resume later right "
+                        "where you left off. See 'man tasksh' for more details.";
+
+  std::vector <std::string> lines;
+  wrapText (lines, welcome, width, false);
+  welcome = join ("\n", lines);
+
+  return "\n" + welcome + "\n\n";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+static const std::string banner (
+  unsigned int current,
+  unsigned int total,
+  unsigned int width,
+  const std::string& message)
+{
+  std::stringstream progress;
+  progress << " ["
+           << current
+           << " of "
+           << total
+           << "] ";
+
+  Color progressColor ("color15 on color9");
+  Color descColor     ("color15 on gray6");
+
+  std::string composed;
+  if (progress.str ().length () + message.length () + 1 < width)
+    composed = progressColor.colorize (progress.str ()) +
+               descColor.colorize (" " + message +
+                 std::string (width - progress.str ().length () - message.length () - 1, ' '));
+  else
+    composed = progressColor.colorize (progress.str ()) +
+               descColor.colorize (" " + message.substr (0, message.length () - 3) + "...");
+
+  return composed + "\n";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+static const std::string menu ()
+{
+  return Color ("color15 on gray6").colorize (" (Enter) Mark as reviewed, (s)kip, (e)dit, (m)odify, (c)omplete, (d)elete, (q)uit ") + " ";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+static void reviewLoop (const std::vector <std::string>& uuids, unsigned int limit, bool autoClear)
+{
+  auto width = getWidth ();
+  unsigned int reviewed = 0;
+
+  // If a limit was specified ('review 10'), then it should override the data
+  // set size, if it is smaller.
+  unsigned int total = uuids.size ();
+  if (limit)
+    total = std::min (total, limit);
+
+  if (total == 0)
+  {
+    std::cout << reviewNothing ();
+    return;
+  }
+
+  std::cout << reviewStart (width);
+
+  unsigned int current = 0;
+  while (current < total &&
+         (limit == 0 || reviewed < limit))
+  {
+    // Run 'info' report for task.
+    auto uuid = uuids[current];
+
+    // Display banner for this task.
+    std::string dummy;
+    std::string description;
+    execute ("task",
+             {"_get", uuid + ".description"},
+             dummy,
+             description);
+
+    std::string response;
+    bool repeat;
+    do
+    {
+      repeat = false;
+      std::cout << banner (current + 1, total, width, Lexer::trimRight (description, "\n"));
+
+      // Use 'system' to run the command and show the output.
+      std::string command = "task " + uuid + " information";
+      system (command.c_str ());
+
+      // Display prompt, get input.
+      response = getResponse (menu ());
+
+           if (response == "e") { editTask (uuid);                                   }
+      else if (response == "m") { modifyTask (uuid);          repeat = true;         }
+      else if (response == "s") { std::cout << "Skipped\n\n"; ++current;             }
+      else if (response == "c") { completeTask (uuid);        ++current; ++reviewed; }
+      else if (response == "d") { deleteTask (uuid);          ++current; ++reviewed; }
+      else if (response == "")  { reviewTask (uuid);          ++current; ++reviewed; }
+      else if (response == "r") { reviewTask (uuid);          ++current; ++reviewed; }
+      else if (response == "q") { break;                                             }
+
+      else
+      {
+        std::cout << format ("Command '{1}' is not recognized.", response) << "\n";
+      }
+
+      // Note that just hitting <Enter> yields an empty command, which does
+      // nothing but advance to the next task.
+
+      if (autoClear)
+        std::cout << "\033[2J\033[0;0H";
+    }
+    while (repeat);
+
+    if (response == "q")
+      break;
+  }
+
+  std::cout << "\n"
+            << format ("End of review. {1} out of {2} tasks reviewed.", reviewed, total)
+            << "\n\n";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int cmdReview (const std::vector <std::string>& args, bool autoClear)
+{
+  // Is there a specified limit?
+  unsigned int limit = 0;
+  if (args.size () == 2)
+    limit = strtol (args[1].c_str (), NULL, 10);
+
+  // Configure 'reviewed' UDA, but only if necessary.
+  std::string input;
+  std::string output;
+  auto status = execute ("task", {"_get", "rc.uda.reviewed.type"}, input, output);
+  if (status || output != "date\n")
+  {
+    if (confirm ("Tasksh needs to define a 'reviewed' UDA of type 'date' for all tasks.  Ok to proceed?"))
+    {
+      execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "uda.reviewed.type",  "date"},     input, output);
+      execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "uda.reviewed.label", "Reviewed"}, input, output);
+    }
+  }
+
+  // Configure '_reviewed' report, but only if necessary.
+  status = execute ("task", {"_get", "rc.report._reviewed.columns"}, input, output);
+  if (status || output != "uuid\n")
+  {
+    if (confirm ("Tasksh needs to define a '_reviewed' report to identify tasks needing review.  Ok to proceed?"))
+    {
+      execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "report._reviewed.description",
+                        "Tasksh review report.  Adjust the filter to your needs."                                              }, input, output);
+      execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "report._reviewed.columns", "uuid"               }, input, output);
+      execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "report._reviewed.sort",    "reviewed+,modified+"}, input, output);
+      execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "report._reviewed.filter",
+                        "( reviewed.none: or reviewed.before:now-6days ) and ( +PENDING or +WAITING )"                         }, input, output);
+    }
+  }
+
+  // Obtain a list of UUIDs to review.
+  status = execute ("task",
+                    {
+                      "rc.color=off",
+                      "rc.detection=off",
+                      "rc._forcecolor=off",
+                      "rc.verbose=nothing",
+                      "_reviewed"
+                    },
+                    input, output);
+
+  // Review the set of UUIDs.
+  auto uuids = split (Lexer::trimRight (output, "\n"), '\n');
+  reviewLoop (uuids, limit, autoClear);
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////
index 8c145901029da80226f3dc83114858966d17d1f2..04900a5f4343fedb17f38b3d700a52a849f5bc33 100644 (file)
@@ -1,6 +1,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 //
-// Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez.
+// Copyright 2006 - 2017, Paul Beckingham, Federico Hernandez
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal