|
|
|
@ -17,8 +17,6 @@
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
|
|
|
|
|
|
NAMESPACE = 'tty' |
|
|
|
|
|
|
|
|
|
import mitterlib.ui.console_utils as console_utils |
|
|
|
|
import logging |
|
|
|
|
from mitterlib.network.networkbase import NetworkError |
|
|
|
@ -27,41 +25,11 @@ from mitterlib.network import NetworksNoNetworkSetupError, NetworksError
|
|
|
|
|
_log = logging.getLogger('ui.tty') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def options(options): |
|
|
|
|
"""Add command line options for this interface.""" |
|
|
|
|
options.add_group(NAMESPACE, 'TTY interface') # This surely needs a |
|
|
|
|
# better description |
|
|
|
|
options.add_option('--messages', |
|
|
|
|
group=NAMESPACE, |
|
|
|
|
option='messages', |
|
|
|
|
help='Display the latest messages.', |
|
|
|
|
default=False, |
|
|
|
|
action='store_true', |
|
|
|
|
is_config_option=False, |
|
|
|
|
conflict_group='interface') |
|
|
|
|
options.add_option('--update', |
|
|
|
|
group=NAMESPACE, |
|
|
|
|
option='update', |
|
|
|
|
default=None, |
|
|
|
|
help='Update your status', |
|
|
|
|
metavar='STATUS', |
|
|
|
|
type='str', |
|
|
|
|
is_config_option=False, |
|
|
|
|
conflict_group='interface') |
|
|
|
|
options.add_option('--replies', |
|
|
|
|
group=NAMESPACE, |
|
|
|
|
option='replies', |
|
|
|
|
help='Get a list of replies instead of the friends timeline', |
|
|
|
|
default=False, |
|
|
|
|
action='store_true', |
|
|
|
|
is_config_option=False, |
|
|
|
|
conflict_group='interface') |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Interface(object): |
|
|
|
|
"""The console/tty interface for Mitter.""" |
|
|
|
|
|
|
|
|
|
NAMESPACE = 'tty' |
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------- |
|
|
|
|
# Private functions |
|
|
|
|
# ----------------------------------------------------------------------- |
|
|
|
@ -117,14 +85,45 @@ class Interface(object):
|
|
|
|
|
|
|
|
|
|
def __call__(self): |
|
|
|
|
"""The callable function, used by mitter to start the interface.""" |
|
|
|
|
status_message = self._options[NAMESPACE]['update'] |
|
|
|
|
status_message = self._options[self.NAMESPACE]['update'] |
|
|
|
|
if status_message: |
|
|
|
|
self._update(status_message) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
if self._options[NAMESPACE]['replies']: |
|
|
|
|
if self._options[self.NAMESPACE]['replies']: |
|
|
|
|
self._replies() |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
self._messages() |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
def options(self, options): |
|
|
|
|
"""Add command line options for this interface.""" |
|
|
|
|
options.add_group(self.NAMESPACE, 'TTY interface') |
|
|
|
|
options.add_option('--messages', |
|
|
|
|
group=self.NAMESPACE, |
|
|
|
|
option='messages', |
|
|
|
|
help='Display the latest messages.', |
|
|
|
|
default=False, |
|
|
|
|
action='store_true', |
|
|
|
|
is_config_option=False, |
|
|
|
|
conflict_group='interface') |
|
|
|
|
options.add_option('--update', |
|
|
|
|
group=self.NAMESPACE, |
|
|
|
|
option='update', |
|
|
|
|
default=None, |
|
|
|
|
help='Update your status', |
|
|
|
|
metavar='STATUS', |
|
|
|
|
type='str', |
|
|
|
|
is_config_option=False, |
|
|
|
|
conflict_group='interface') |
|
|
|
|
options.add_option('--replies', |
|
|
|
|
group=self.NAMESPACE, |
|
|
|
|
option='replies', |
|
|
|
|
help='Get a list of replies instead of the friends timeline', |
|
|
|
|
default=False, |
|
|
|
|
action='store_true', |
|
|
|
|
is_config_option=False, |
|
|
|
|
conflict_group='interface') |
|
|
|
|
return |
|
|
|
|