diff --git a/src/commands/CMakeLists.txt b/src/commands/CMakeLists.txt index 8122366e4..12d688740 100644 --- a/src/commands/CMakeLists.txt +++ b/src/commands/CMakeLists.txt @@ -5,7 +5,8 @@ include_directories (${CMAKE_SOURCE_DIR}/src ${TASK_INCLUDE_DIRS}) set (commands_SRCS Command.cpp Command.h - Install.cpp Install.h) + CmdInstall.cpp CmdInstall.h + CmdLogo.cpp CmdLogo.h) add_library (commands STATIC ${commands_SRCS}) diff --git a/src/commands/Install.cpp b/src/commands/CmdInstall.cpp similarity index 86% rename from src/commands/Install.cpp rename to src/commands/CmdInstall.cpp index d99ea85db..432273176 100644 --- a/src/commands/Install.cpp +++ b/src/commands/CmdInstall.cpp @@ -26,13 +26,13 @@ //////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include extern Context context; //////////////////////////////////////////////////////////////////////////////// -Install::Install () +CmdInstall::CmdInstall () /* : _name ("") */ @@ -40,7 +40,7 @@ Install::Install () } //////////////////////////////////////////////////////////////////////////////// -Install::Install (const Install& other) +CmdInstall::CmdInstall (const CmdInstall& other) { /* _minimum = other._minimum; @@ -48,7 +48,7 @@ Install::Install (const Install& other) } //////////////////////////////////////////////////////////////////////////////// -Install& Install::operator= (const Install& other) +CmdInstall& CmdInstall::operator= (const CmdInstall& other) { if (this != &other) { @@ -61,7 +61,7 @@ Install& Install::operator= (const Install& other) } //////////////////////////////////////////////////////////////////////////////// -bool Install::operator== (const Install& other) const +bool CmdInstall::operator== (const CmdInstall& other) const { return false; /* @@ -75,18 +75,18 @@ bool Install::operator== (const Install& other) const } //////////////////////////////////////////////////////////////////////////////// -Install::~Install () +CmdInstall::~CmdInstall () { } //////////////////////////////////////////////////////////////////////////////// -bool Install::read_only () const +bool CmdInstall::read_only () const { return false; } //////////////////////////////////////////////////////////////////////////////// -bool Install::implements (const std::string& command_line) const +bool CmdInstall::implements (const std::string& command_line) const { return false; } @@ -97,7 +97,7 @@ bool Install::implements (const std::string& command_line) const // Generate UUID // Call the "install" function once, store results in rc: // extension.= -std::string Install::execute (const std::string&) +std::string CmdInstall::execute (const std::string&) { return "output"; } diff --git a/src/commands/CmdInstall.h b/src/commands/CmdInstall.h new file mode 100644 index 000000000..14c0eb574 --- /dev/null +++ b/src/commands/CmdInstall.h @@ -0,0 +1,50 @@ +//////////////////////////////////////////////////////////////////////////////// +// taskwarrior - a command line task list manager. +// +// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_CMDINSTALL +#define INCLUDED_CMDINSTALL + +#include +#include + +class CmdInstall : public Command +{ +public: + CmdInstall (); + CmdInstall (const CmdInstall&); + CmdInstall& operator= (const CmdInstall&); + bool operator== (const CmdInstall&) const; // TODO Is this necessary? + ~CmdInstall (); + + bool read_only () const; + bool implements (const std::string&) const; + std::string execute (const std::string&); + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/CmdLogo.cpp b/src/commands/CmdLogo.cpp new file mode 100644 index 000000000..e8536de8a --- /dev/null +++ b/src/commands/CmdLogo.cpp @@ -0,0 +1,171 @@ +//////////////////////////////////////////////////////////////////////////////// +// taskwarrior - a command line task list manager. +// +// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include + +extern Context context; + +//////////////////////////////////////////////////////////////////////////////// +CmdLogo::CmdLogo () +/* +: _name ("") +*/ +{ +} + +//////////////////////////////////////////////////////////////////////////////// +CmdLogo::CmdLogo (const CmdLogo& other) +{ +/* + _minimum = other._minimum; +*/ +} + +//////////////////////////////////////////////////////////////////////////////// +CmdLogo& CmdLogo::operator= (const CmdLogo& other) +{ + if (this != &other) + { +/* + _name = other._name; +*/ + } + + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +bool CmdLogo::operator== (const CmdLogo& other) const +{ + return false; +/* + return _name == other._name && + _minimum == other._minimum && + _maximum == other._maximum && + _wrap == other._wrap && + _just == other._just && + _sizing == other._sizing; +*/ +} + +//////////////////////////////////////////////////////////////////////////////// +CmdLogo::~CmdLogo () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +bool CmdLogo::read_only () const +{ + return false; +} + +//////////////////////////////////////////////////////////////////////////////// +bool CmdLogo::implements (const std::string& command_line) const +{ + return false; +} + +//////////////////////////////////////////////////////////////////////////////// +// Algorithm: +// Copy file rc.data.location/extensions +// Generate UUID +// Call the "install" function once, store results in rc: +// extension.= +std::string CmdLogo::execute (const std::string&) +{ + static const char* data[] = + { + ".........ABDEF", + ".......BDILNMM", + ".....ACJNLHFEE", + "....AFMMFDEEEE", + "...AFOIDEEEEDD", + "..AFOHDEEEDIOR", + "..DMIDEEEEOXXX", + ".BJMDEEEDMXXXX", + ".ENFEEEEFVXXXX", + "BILDEEEEJXXXXX", + "DLHEEEEDLXXXXX", + "GMFEEEEDKXXXXX", + "GMEEEEEEGTIKOR", + "GMEEEEEEETODDD", + "GMEEEEEEETXRGE", + "GMEEEEEEFVXXSE", + "ENFEEEEEHWXXUE", + "CLHEEEEDLXXXUE", + "AILDEEEDRXXXUE", + ".DNFEEEEPXXXUE", + ".BJMDEEEEPXXUE", + "..DMIDEEEDLXUE", + "..AFOHDEEEDHME", + "...AFOIDEEEEDE", + "....AFMMFDEEEE", + ".....ACJNLHFEE", + ".......BDILNMM", + ".........ABDEF", + "" + }; + + std::string output; + for (int line = 0; data[line][0]; ++line) + { + + for (int c = 0; c < 14; ++c) + { + int value = (int) data[line][c]; + if (value == '.') + output += " "; + else + { + value += 167; + char block [24]; + sprintf (block, "\033[48;5;%dm \033[0m", value); + output += block; + } + } + + for (int c = 13; c >= 0; --c) + { + int value = data[line][c]; + if (value == '.') + output += " "; + else + { + value += 167; + char block [24]; + sprintf (block, "\033[48;5;%dm \033[0m", value); + output += block; + } + } + } + + return output; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/Install.h b/src/commands/CmdLogo.h similarity index 84% rename from src/commands/Install.h rename to src/commands/CmdLogo.h index 525ec1de5..0f742cb20 100644 --- a/src/commands/Install.h +++ b/src/commands/CmdLogo.h @@ -24,20 +24,20 @@ // USA // //////////////////////////////////////////////////////////////////////////////// -#ifndef INCLUDED_INSTALL -#define INCLUDED_INSTALL +#ifndef INCLUDED_CMDLOGO +#define INCLUDED_CMDLOGO #include #include -class Install : public Command +class CmdLogo : public Command { public: - Install (); - Install (const Install&); - Install& operator= (const Install&); - bool operator== (const Install&) const; // TODO Is this necessary? - ~Install (); + CmdLogo (); + CmdLogo (const CmdLogo&); + CmdLogo& operator= (const CmdLogo&); + bool operator== (const CmdLogo&) const; // TODO Is this necessary? + ~CmdLogo (); bool read_only () const; bool implements (const std::string&) const; diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index 6e07e9db1..0b900e2c4 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -27,7 +27,8 @@ #include #include -#include +#include +#include #include extern Context context; @@ -35,10 +36,13 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// Command* Command::factory (const std::string& name) { - if (name == "install") return new Install (); + Command* command; + if (name == "install") command = new CmdInstall (); + else if (name == "_logo") command = new CmdLogo (); + else + throw std::string ("Unrecognized command '") + name + "'"; - throw std::string ("Unrecognized command '") + name + "'"; - return NULL; + return command; } ////////////////////////////////////////////////////////////////////////////////