|
|
@ -17,8 +17,6 @@ |
|
|
|
# You should have received a copy of the GNU General Public License |
|
|
|
# You should have received a copy of the GNU General Public License |
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
|
|
|
|
|
|
|
|
NAMESPACE = 'tty' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import mitterlib.ui.console_utils as console_utils |
|
|
|
import mitterlib.ui.console_utils as console_utils |
|
|
|
import logging |
|
|
|
import logging |
|
|
|
from mitterlib.network.networkbase import NetworkError |
|
|
|
from mitterlib.network.networkbase import NetworkError |
|
|
@ -27,41 +25,11 @@ from mitterlib.network import NetworksNoNetworkSetupError, NetworksError |
|
|
|
_log = logging.getLogger('ui.tty') |
|
|
|
_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): |
|
|
|
class Interface(object): |
|
|
|
"""The console/tty interface for Mitter.""" |
|
|
|
"""The console/tty interface for Mitter.""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NAMESPACE = 'tty' |
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------- |
|
|
|
# ----------------------------------------------------------------------- |
|
|
|
# Private functions |
|
|
|
# Private functions |
|
|
|
# ----------------------------------------------------------------------- |
|
|
|
# ----------------------------------------------------------------------- |
|
|
@ -117,14 +85,45 @@ class Interface(object): |
|
|
|
|
|
|
|
|
|
|
|
def __call__(self): |
|
|
|
def __call__(self): |
|
|
|
"""The callable function, used by mitter to start the interface.""" |
|
|
|
"""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: |
|
|
|
if status_message: |
|
|
|
self._update(status_message) |
|
|
|
self._update(status_message) |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
if self._options[NAMESPACE]['replies']: |
|
|
|
if self._options[self.NAMESPACE]['replies']: |
|
|
|
self._replies() |
|
|
|
self._replies() |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
self._messages() |
|
|
|
self._messages() |
|
|
|
return |
|
|
|
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 |
|
|
|