mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Tasksh
- Took the broken tasksh program out back behind the barn and shot it. It will be rewritten as a separate project, and extension.
This commit is contained in:
parent
63eb32d177
commit
ff966c069c
20 changed files with 4 additions and 692 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,13 +1,10 @@
|
||||||
cmake.h
|
cmake.h
|
||||||
auto.h
|
|
||||||
commit.h
|
commit.h
|
||||||
Makefile
|
Makefile
|
||||||
src/task
|
src/task
|
||||||
src/libtask.a
|
src/libtask.a
|
||||||
src/commands/libcommands.a
|
src/commands/libcommands.a
|
||||||
src/columns/libcolumns.a
|
src/columns/libcolumns.a
|
||||||
src/shell/libtasksh.a
|
|
||||||
src/shell/tasksh
|
|
||||||
*~
|
*~
|
||||||
.*.swp
|
.*.swp
|
||||||
package-config/osx/binary/task
|
package-config/osx/binary/task
|
||||||
|
|
|
@ -149,7 +149,6 @@ configure_file (
|
||||||
add_subdirectory (src)
|
add_subdirectory (src)
|
||||||
add_subdirectory (src/commands)
|
add_subdirectory (src/commands)
|
||||||
add_subdirectory (src/columns)
|
add_subdirectory (src/columns)
|
||||||
add_subdirectory (src/shell)
|
|
||||||
add_subdirectory (doc)
|
add_subdirectory (doc)
|
||||||
add_subdirectory (i18n)
|
add_subdirectory (i18n)
|
||||||
add_subdirectory (scripts)
|
add_subdirectory (scripts)
|
||||||
|
@ -173,6 +172,5 @@ set (CPACK_SOURCE_IGNORE_FILES "CMakeCache" "CMakeFiles" "CPackConfig" "CPackSo
|
||||||
"_CPack_Packages" "cmake_install" "install_manifest" "Makefile$"
|
"_CPack_Packages" "cmake_install" "install_manifest" "Makefile$"
|
||||||
"test" "package-config" "misc/*" "src/task$" "src/libtask.a"
|
"test" "package-config" "misc/*" "src/task$" "src/libtask.a"
|
||||||
"src/columns/libcolumns.a" "src/commands/libcommands.a"
|
"src/columns/libcolumns.a" "src/commands/libcommands.a"
|
||||||
"src/shell/tasksh$" "src/shell/libtasksh.a" "auto.h$"
|
|
||||||
"/\\.gitignore" "/\\.git/" "swp$")
|
"/\\.gitignore" "/\\.git/" "swp$")
|
||||||
include (CPack)
|
include (CPack)
|
||||||
|
|
3
NEWS
3
NEWS
|
@ -39,6 +39,9 @@ Removed features in 2.4.0
|
||||||
- Removed the unused 'patterns' confguration variable.
|
- Removed the unused 'patterns' confguration variable.
|
||||||
- Removed the obsolete 'task-faq.5' man page.
|
- Removed the obsolete 'task-faq.5' man page.
|
||||||
- Removed the obsolete 'task-tutorial.5' man page.
|
- Removed the obsolete 'task-tutorial.5' man page.
|
||||||
|
- Removed the obsolete 'tasksh.1' man page.
|
||||||
|
- Removed the 'tasksh' program from the Taskwarrior distribution. It is now
|
||||||
|
a separate project.
|
||||||
|
|
||||||
Known Issues
|
Known Issues
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required (VERSION 2.8)
|
cmake_minimum_required (VERSION 2.8)
|
||||||
message ("-- Configuring man pages")
|
message ("-- Configuring man pages")
|
||||||
set (man_FILES task-color.5 task-sync.5 taskrc.5 task.1 tasksh.1)
|
set (man_FILES task-color.5 task-sync.5 taskrc.5 task.1)
|
||||||
foreach (man_FILE ${man_FILES})
|
foreach (man_FILE ${man_FILES})
|
||||||
configure_file (
|
configure_file (
|
||||||
man/${man_FILE}.in
|
man/${man_FILE}.in
|
||||||
|
|
1
doc/man/.gitignore
vendored
1
doc/man/.gitignore
vendored
|
@ -2,4 +2,3 @@ task-color.5
|
||||||
task-sync.5
|
task-sync.5
|
||||||
task.1
|
task.1
|
||||||
taskrc.5
|
taskrc.5
|
||||||
tasksh.1
|
|
||||||
|
|
|
@ -311,7 +311,6 @@ http://www.opensource.org/licenses/mit-license.php for more information.
|
||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR task(1),
|
.BR task(1),
|
||||||
.BR tasksh(1),
|
|
||||||
.BR taskrc(5),
|
.BR taskrc(5),
|
||||||
.BR task-sync(5)
|
.BR task-sync(5)
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,6 @@ http://www.opensource.org/licenses/mit-license.php for more information.
|
||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR task(1),
|
.BR task(1),
|
||||||
.BR tasksh(1),
|
|
||||||
.BR taskrc(5),
|
.BR taskrc(5),
|
||||||
.BR task-color(5),
|
.BR task-color(5),
|
||||||
|
|
||||||
|
|
|
@ -1094,7 +1094,6 @@ Taskwarrior is distributed under the MIT license. See
|
||||||
http://www.opensource.org/licenses/mit-license.php for more information.
|
http://www.opensource.org/licenses/mit-license.php for more information.
|
||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR tasksh(1),
|
|
||||||
.BR taskrc(5),
|
.BR taskrc(5),
|
||||||
.BR task-color(5),
|
.BR task-color(5),
|
||||||
.BR task-sync(5)
|
.BR task-sync(5)
|
||||||
|
|
|
@ -1383,7 +1383,6 @@ http://www.opensource.org/licenses/mit-license.php for more information.
|
||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR task(1),
|
.BR task(1),
|
||||||
.BR tasksh(1),
|
|
||||||
.BR task-color(5),
|
.BR task-color(5),
|
||||||
.BR task-sync(5)
|
.BR task-sync(5)
|
||||||
|
|
||||||
|
|
|
@ -1,183 +0,0 @@
|
||||||
.TH tasksh 1 2014-01-15 "${PACKAGE_STRING}" "User Manuals"
|
|
||||||
|
|
||||||
.SH NAME
|
|
||||||
tasksh \- Interactive taskwarrior shell
|
|
||||||
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B tasksh [<commands-file>]
|
|
||||||
.br
|
|
||||||
.B tasksh --version
|
|
||||||
.br
|
|
||||||
.B tasksh --help
|
|
||||||
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The tasksh program can be used to create a more immersive task 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".
|
|
||||||
|
|
||||||
.br
|
|
||||||
Moreover, task commands can be written in a file which can be passed or
|
|
||||||
redirected to tasksh for batch execution.
|
|
||||||
|
|
||||||
.RS
|
|
||||||
$ tasksh
|
|
||||||
.br
|
|
||||||
.B task 2.3.0
|
|
||||||
shell
|
|
||||||
.br
|
|
||||||
|
|
||||||
.br
|
|
||||||
Enter any task command (such as 'list'), or hit 'Enter'.
|
|
||||||
.br
|
|
||||||
There is no need to include the 'task' command itself.
|
|
||||||
.br
|
|
||||||
Enter 'quit' to end the session.
|
|
||||||
.br
|
|
||||||
|
|
||||||
.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/2010 2 hrs Select and book a venue
|
|
||||||
.br
|
|
||||||
5 party H 10/22/2010 2 hrs Design invitations
|
|
||||||
.br
|
|
||||||
9 home 10/31/2010 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
|
|
||||||
$ cat task.commands
|
|
||||||
.br
|
|
||||||
add foo
|
|
||||||
.br
|
|
||||||
add bar
|
|
||||||
.br
|
|
||||||
$ tasksh task.commands
|
|
||||||
.br
|
|
||||||
task 2.3.0 shell
|
|
||||||
.br
|
|
||||||
|
|
||||||
.br
|
|
||||||
Enter any task command (such as 'list'), or hit 'Enter'.
|
|
||||||
.br
|
|
||||||
There is no need to include the 'task' command itself.
|
|
||||||
.br
|
|
||||||
Enter 'quit' to end the session.
|
|
||||||
.br
|
|
||||||
|
|
||||||
.br
|
|
||||||
task> add foo
|
|
||||||
.br
|
|
||||||
Created task 8.
|
|
||||||
.br
|
|
||||||
task> add bar
|
|
||||||
.br
|
|
||||||
Created task 9.
|
|
||||||
.br
|
|
||||||
$
|
|
||||||
.br
|
|
||||||
$ cat task.commands | tasksh
|
|
||||||
.br
|
|
||||||
task 2.3.0 shell
|
|
||||||
.br
|
|
||||||
|
|
||||||
.br
|
|
||||||
Enter any task command (such as 'list'), or hit 'Enter'.
|
|
||||||
.br
|
|
||||||
There is no need to include the 'task' command itself.
|
|
||||||
.br
|
|
||||||
Enter 'quit' to end the session.
|
|
||||||
.br
|
|
||||||
|
|
||||||
.br
|
|
||||||
task> add foo
|
|
||||||
.br
|
|
||||||
Created task 8.
|
|
||||||
.br
|
|
||||||
task> add bar
|
|
||||||
.br
|
|
||||||
Created task 9.
|
|
||||||
.br
|
|
||||||
|
|
||||||
.RE
|
|
||||||
|
|
||||||
.SH "CREDITS & COPYRIGHTS"
|
|
||||||
Copyright (C) 2006 \- 2014 P. Beckingham, F. Hernandez.
|
|
||||||
|
|
||||||
This man page was originally written by Federico Hernandez.
|
|
||||||
|
|
||||||
Taskwarrior is distributed under the MIT license. See
|
|
||||||
http://www.opensource.org/licenses/mit-license.php for more information.
|
|
||||||
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR task(1),
|
|
||||||
.BR taskrc(5),
|
|
||||||
.BR task-color(5),
|
|
||||||
.BR task-sync(5)
|
|
||||||
|
|
||||||
For more information regarding taskwarrior, see the following:
|
|
||||||
|
|
||||||
.TP
|
|
||||||
The official site at
|
|
||||||
<http://taskwarrior.org>
|
|
||||||
|
|
||||||
.TP
|
|
||||||
The official code repository at
|
|
||||||
<https://git.tasktools.org/scm/tm/task.git>
|
|
||||||
|
|
||||||
.TP
|
|
||||||
You can contact the project by emailing
|
|
||||||
<support@taskwarrior.org>
|
|
||||||
|
|
||||||
.SH REPORTING BUGS
|
|
||||||
.TP
|
|
||||||
Bugs in taskwarrior may be reported to the issue-tracker at
|
|
||||||
<http://taskwarrior.org>
|
|
||||||
|
|
|
@ -938,14 +938,5 @@
|
||||||
#define STRING_UTIL_KIBIBYTES "KiB"
|
#define STRING_UTIL_KIBIBYTES "KiB"
|
||||||
#define STRING_UTIL_BYTES "B"
|
#define STRING_UTIL_BYTES "B"
|
||||||
|
|
||||||
// shell
|
|
||||||
#define STRING_SHELL_USAGE \
|
|
||||||
"Usage: tasksh [<commands-file>] Execute task commands inside <commands-file> if given,\n" \
|
|
||||||
" or otherwise, start interactive task shell.\n" \
|
|
||||||
" tasksh --version Print task version.\n" \
|
|
||||||
" tasksh --help Print this help.\n"
|
|
||||||
|
|
||||||
#define STRING_SHELL_NO_FILE "Input file does not exist.\n"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -968,14 +968,5 @@
|
||||||
#define STRING_UTIL_KIBIBYTES "KiB" // |esp-ESP|==|eng-USA|
|
#define STRING_UTIL_KIBIBYTES "KiB" // |esp-ESP|==|eng-USA|
|
||||||
#define STRING_UTIL_BYTES "B" // |esp-ESP|==|eng-USA|
|
#define STRING_UTIL_BYTES "B" // |esp-ESP|==|eng-USA|
|
||||||
|
|
||||||
// shell
|
|
||||||
#define STRING_SHELL_USAGE \
|
|
||||||
"Uso: tasksh [<fichero-comandos>] Ejecuta los comandos task contenidos en <fichero-comandos>, si se indica;\n" \
|
|
||||||
" si no, lanza un entorno interactivo de comandos task.\n" \
|
|
||||||
" tasksh --version Muestra la versión de task.\n" \
|
|
||||||
" tasksh --help Muestra esta ayuda.\n"
|
|
||||||
|
|
||||||
#define STRING_SHELL_NO_FILE "El fichero de entrada no existe.\n"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -937,14 +937,5 @@
|
||||||
#define STRING_UTIL_KIBIBYTES "KiB"
|
#define STRING_UTIL_KIBIBYTES "KiB"
|
||||||
#define STRING_UTIL_BYTES "B"
|
#define STRING_UTIL_BYTES "B"
|
||||||
|
|
||||||
// shell
|
|
||||||
#define STRING_SHELL_USAGE \
|
|
||||||
"Usage: tasksh [<commands-file>] Execute task commands inside <commands-file> if given,\n" \
|
|
||||||
" or otherwise, start interactive task shell.\n" \
|
|
||||||
" tasksh --version Print task version.\n" \
|
|
||||||
" tasksh --help Print this help.\n"
|
|
||||||
|
|
||||||
#define STRING_SHELL_NO_FILE "Input file does not exist.\n"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -938,14 +938,5 @@
|
||||||
#define STRING_UTIL_KIBIBYTES "Kb"
|
#define STRING_UTIL_KIBIBYTES "Kb"
|
||||||
#define STRING_UTIL_BYTES "B"
|
#define STRING_UTIL_BYTES "B"
|
||||||
|
|
||||||
// shell
|
|
||||||
#define STRING_SHELL_USAGE \
|
|
||||||
"Uso: tasksh [<commands-file>] Esegue i comandi all'interno di <commands-file> se fornito,\n" \
|
|
||||||
" oppure avvia la shell interattiva.\n" \
|
|
||||||
" tasksh --version Stampa la versione di task.\n" \
|
|
||||||
" tasksh --help Stampa questo aiuto.\n"
|
|
||||||
|
|
||||||
#define STRING_SHELL_NO_FILE "Il file di input non esiste.\n"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -938,14 +938,5 @@
|
||||||
#define STRING_UTIL_KIBIBYTES "KiB" // |por-PRT|==|eng-USA|
|
#define STRING_UTIL_KIBIBYTES "KiB" // |por-PRT|==|eng-USA|
|
||||||
#define STRING_UTIL_BYTES "B" // |por-PRT|==|eng-USA|
|
#define STRING_UTIL_BYTES "B" // |por-PRT|==|eng-USA|
|
||||||
|
|
||||||
// shell
|
|
||||||
#define STRING_SHELL_USAGE \
|
|
||||||
"Uso: tasksh [<ficheiro-comandos>] Executa os comandos 'task' contidos no <ficheiro-comandos>\n" \
|
|
||||||
" se fornecido ou alternativamente inicia a shell interativa.\n" \
|
|
||||||
" tasksh --version Mostra a versão do taskwarrior.\n" \
|
|
||||||
" tasksh --help Mostra esta ajuda.\n"
|
|
||||||
|
|
||||||
#define STRING_SHELL_NO_FILE "O ficheiro de input não existe.\n"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
cmake_minimum_required (VERSION 2.8)
|
|
||||||
include_directories (${CMAKE_SOURCE_DIR}
|
|
||||||
${CMAKE_SOURCE_DIR}/src
|
|
||||||
${CMAKE_SOURCE_DIR}/src/commands
|
|
||||||
${CMAKE_SOURCE_DIR}/src/columns
|
|
||||||
${CMAKE_SOURCE_DIR}/src/shell
|
|
||||||
${TASK_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
set (tasksh_SRCS Readline.cpp Readline.h)
|
|
||||||
|
|
||||||
add_library (tasksh STATIC ${tasksh_SRCS})
|
|
||||||
add_executable (tasksh_executable main.cpp)
|
|
||||||
|
|
||||||
# Yes, 'task' is included twice, otherwise linking fails on CentOS.
|
|
||||||
target_link_libraries (tasksh_executable task commands columns tasksh task ${TASK_LIBRARIES})
|
|
||||||
|
|
||||||
set_property (TARGET tasksh_executable PROPERTY OUTPUT_NAME "tasksh")
|
|
||||||
|
|
||||||
install (TARGETS tasksh_executable DESTINATION ${TASK_BINDIR})
|
|
|
@ -1,76 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Copyright 2006 - 2014, 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 <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <Readline.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_READLINE
|
|
||||||
#include <readline/readline.h>
|
|
||||||
#include <readline/history.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
std::string Readline::gets (const std::string& prompt)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_READLINE
|
|
||||||
// Get a line from the user.
|
|
||||||
char *line_read = readline (prompt.c_str ());
|
|
||||||
if (!line_read) // Exit when CTRL-D is pressed
|
|
||||||
{
|
|
||||||
std::cout << "exit\n";
|
|
||||||
return "exit";
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
std::string line_read;
|
|
||||||
std::cout << prompt;
|
|
||||||
std::getline (std::cin, line_read);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_READLINE
|
|
||||||
// If the line has any text in it, save it on the history.
|
|
||||||
if (*line_read)
|
|
||||||
add_history (line_read);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string ret(line_read);
|
|
||||||
|
|
||||||
#ifdef HAVE_READLINE
|
|
||||||
free (line_read);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool Readline::interactiveMode (const std::istream& in)
|
|
||||||
{
|
|
||||||
return (&in == &std::cin && isatty (0) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
|
@ -1,52 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Copyright 2006 - 2014, 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
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef INCLUDED_READLINE
|
|
||||||
#define INCLUDED_READLINE
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <stdio.h>
|
|
||||||
#ifdef HAVE_WORDEXP
|
|
||||||
#include <wordexp.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Static class that offers a C++ API to readline C functions.
|
|
||||||
class Readline
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static std::string gets (const std::string& prompt);
|
|
||||||
static bool interactiveMode (const std::istream& in);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// No construction or destruction.
|
|
||||||
Readline (); // Don't implement.
|
|
||||||
~Readline (); // Don't implement.
|
|
||||||
Readline (const Readline&); // Don't implement.
|
|
||||||
Readline& operator= (const Readline&); // Don't implement.
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
|
@ -1,245 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Copyright 2006 - 2014, 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 <algorithm>
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <cstring>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <text.h>
|
|
||||||
#include <i18n.h>
|
|
||||||
#include <Color.h>
|
|
||||||
#include <Context.h>
|
|
||||||
#include <Readline.h>
|
|
||||||
|
|
||||||
Context context;
|
|
||||||
|
|
||||||
#define MAX_ARGUMENTS 256
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
int main (int argc, const char** argv)
|
|
||||||
{
|
|
||||||
bool read_from_file = false;
|
|
||||||
|
|
||||||
if (argc > 2)
|
|
||||||
{
|
|
||||||
std::cout << STRING_SHELL_USAGE << "\n";
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (argc == 2)
|
|
||||||
{
|
|
||||||
if (!strcmp (argv[1], "--version"))
|
|
||||||
{
|
|
||||||
std::cout << VERSION << "\n";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if (!strcmp (argv[1], "--help"))
|
|
||||||
{
|
|
||||||
std::cout << STRING_SHELL_USAGE << "\n";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// The user has given tasksh a task commands file to execute
|
|
||||||
File input_file = File (argv[1]);
|
|
||||||
if (!input_file.exists ())
|
|
||||||
{
|
|
||||||
std::cout << STRING_SHELL_NO_FILE;
|
|
||||||
std::cout << STRING_SHELL_USAGE << "\n";
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
read_from_file = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If a file is given, read from it
|
|
||||||
std::ifstream fin;
|
|
||||||
if (read_from_file)
|
|
||||||
{
|
|
||||||
fin.open (argv[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Commands may be redirected too
|
|
||||||
std::istream &in = read_from_file ? fin : std::cin;
|
|
||||||
|
|
||||||
if (Readline::interactiveMode (in))
|
|
||||||
{
|
|
||||||
// Begining initilaization
|
|
||||||
if (context.initialize (0, NULL))
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display some kind of welcome message.
|
|
||||||
Color bold (Color::nocolor, Color::nocolor, false, true, false);
|
|
||||||
|
|
||||||
std::cout << (context.color () ? bold.colorize (PACKAGE_STRING)
|
|
||||||
: PACKAGE_STRING)
|
|
||||||
<< " shell\n\n"
|
|
||||||
<< STRING_CMD_SHELL_HELP1 << '\n'
|
|
||||||
<< STRING_CMD_SHELL_HELP2 << '\n'
|
|
||||||
<< STRING_CMD_SHELL_HELP3 << "\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make a copy because context.clear will delete them.
|
|
||||||
std::string permanent_overrides;
|
|
||||||
std::vector <Tree*>::iterator i;
|
|
||||||
for (i = context.parser.tree ()->_branches.begin (); i != context.parser.tree ()->_branches.end (); ++i)
|
|
||||||
{
|
|
||||||
if ((*i)->hasTag ("RC") ||
|
|
||||||
(*i)->hasTag ("CONFIG"))
|
|
||||||
{
|
|
||||||
if (i != context.parser.tree ()->_branches.begin ())
|
|
||||||
permanent_overrides += " ";
|
|
||||||
|
|
||||||
permanent_overrides += (*i)->attribute ("raw");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string input;
|
|
||||||
|
|
||||||
std::vector <std::string> quit_commands;
|
|
||||||
quit_commands.push_back ("quit");
|
|
||||||
quit_commands.push_back ("exit");
|
|
||||||
quit_commands.push_back ("bye");
|
|
||||||
|
|
||||||
// The event loop.
|
|
||||||
while (in)
|
|
||||||
{
|
|
||||||
std::string prompt (context.config.get ("shell.prompt") + " ");
|
|
||||||
context.clear ();
|
|
||||||
|
|
||||||
if (Readline::interactiveMode (in))
|
|
||||||
{
|
|
||||||
input = Readline::gets (prompt);
|
|
||||||
|
|
||||||
// if a string has nothing but whitespaces, ignore it
|
|
||||||
if (input.find_first_not_of (" \t") == std::string::npos)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::getline (in, input);
|
|
||||||
|
|
||||||
// if a string has nothing but whitespaces, ignore it
|
|
||||||
if (input.find_first_not_of (" \t") == std::string::npos)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
std::cout << prompt << input << '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
#ifdef HAVE_WORDEXP
|
|
||||||
std::string command = "task " + trim (input + permanent_overrides);
|
|
||||||
|
|
||||||
// Escape special chars.
|
|
||||||
size_t i = 0;
|
|
||||||
while ((i = command.find_first_of ("$*?!|&;<>(){}~#@\\", i)) != std::string::npos)
|
|
||||||
{
|
|
||||||
command.insert(i, 1, '\\');
|
|
||||||
i += 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Perform expansion.
|
|
||||||
wordexp_t p;
|
|
||||||
wordexp (command.c_str (), &p, 0);
|
|
||||||
char** w = p.we_wordv;
|
|
||||||
|
|
||||||
for (int i = 0; i < p.we_wordc; ++i)
|
|
||||||
{
|
|
||||||
if (std::find (quit_commands.begin (), quit_commands.end (),
|
|
||||||
lowerCase (w[i])) != quit_commands.end ())
|
|
||||||
{
|
|
||||||
context.clearMessages ();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// External calls.
|
|
||||||
if (strcmp (w[1], "!") == 0 && p.we_wordc > 2)
|
|
||||||
{
|
|
||||||
std::string combined = "";
|
|
||||||
for (int i = 2; i < p.we_wordc - 1 ; ++i)
|
|
||||||
{
|
|
||||||
combined += std::string (w[i]) + " ";
|
|
||||||
}
|
|
||||||
combined += w[p.we_wordc - 1]; // last goes without a blank
|
|
||||||
system (combined.c_str ()); // not checked
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int status = context.initialize (p.we_wordc, (const char**)p.we_wordv);
|
|
||||||
wordfree(&p);
|
|
||||||
#else
|
|
||||||
std::string command = "task " + trim (input + permanent_overrides);
|
|
||||||
int arg_count = 0;
|
|
||||||
char* arg_vector[MAX_ARGUMENTS];
|
|
||||||
|
|
||||||
char* arg = strtok ((char*)command.c_str (), " ");
|
|
||||||
while (arg && arg_count < MAX_ARGUMENTS)
|
|
||||||
{
|
|
||||||
arg_vector[arg_count++] = arg;
|
|
||||||
arg = strtok (0, " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 1; i < arg_count; ++i)
|
|
||||||
{
|
|
||||||
if (std::find (quit_commands.begin (), quit_commands.end (),
|
|
||||||
lowerCase (arg_vector[i])) != quit_commands.end ())
|
|
||||||
{
|
|
||||||
context.clearMessages ();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int status = context.initialize (arg_count, (const char**) arg_vector);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (status == 0)
|
|
||||||
context.run ();
|
|
||||||
}
|
|
||||||
|
|
||||||
catch (const std::string& error)
|
|
||||||
{
|
|
||||||
std::cerr << error << '\n';
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
std::cerr << STRING_UNKNOWN_ERROR << '\n';
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
61
test/shell.t
61
test/shell.t
|
@ -1,61 +0,0 @@
|
||||||
#! /usr/bin/env perl
|
|
||||||
################################################################################
|
|
||||||
##
|
|
||||||
## Copyright 2006 - 2014, 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
|
|
||||||
##
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use Test::More tests => 3;
|
|
||||||
|
|
||||||
# Ensure environment has no influence.
|
|
||||||
delete $ENV{'TASKDATA'};
|
|
||||||
delete $ENV{'TASKRC'};
|
|
||||||
|
|
||||||
# Create the rc file.
|
|
||||||
if (open my $fh, '>', 'shell.rc')
|
|
||||||
{
|
|
||||||
print $fh "data.location=.\n",
|
|
||||||
"shell.prompt=testprompt>\n",
|
|
||||||
"defaultwidth=0\n",
|
|
||||||
"default.command=ls\n";
|
|
||||||
close $fh;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Test the prompt.
|
|
||||||
my $output = qx{printf "rc:shell.rc add foo\nquit" | ../src/shell/tasksh 2>&1};
|
|
||||||
like ($output, qr/testprompt>/, 'custom prompt is being used');
|
|
||||||
|
|
||||||
# Test a simple add, then info.
|
|
||||||
qx{echo "rc:shell.rc add foo" | ../src/shell/tasksh 2>&1};
|
|
||||||
$output = qx{echo "rc:shell.rc 1 info" | ../src/shell/tasksh 2>&1};
|
|
||||||
like ($output, qr/Description\s+foo/, 'add/info working');
|
|
||||||
|
|
||||||
unlink 'shell.rc';
|
|
||||||
ok (!-r 'shell.rc', 'Removed shell.rc');
|
|
||||||
|
|
||||||
# Cleanup.
|
|
||||||
unlink qw(pending.data completed.data undo.data backlog.data shell.rc);
|
|
||||||
exit 0;
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue