Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar-network
blob: 2dd119411891feb1ae9b45b7930004a590401b79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python

# Copyright (C) 2012 Aleksey Lim
#
# 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 3 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, see <http://www.gnu.org/licenses/>.

from sugar_network.toolkit import application, sugar
from active_toolkit.options import Option
from active_toolkit import enforce


command = Option(
        'if context implementation supports several commands, ' \
                'specify one of them to launch',
        default='activity', short_option='-C')


class Application(application.Application):

    @application.command(
            'CONTEXT [RESTRICTION] [ARGS]\n'
            'if context is associatad with software, launch one of its '
            'implementations')
    def launch(self):
        enforce(self.args, 'Context is not specified')
        #context = self.args.pop(0)
        raise NotImplementedError()

    @application.command(
            'CONTEXT\n'
            'if context is associatad with software, download one of its '
            'implementations and place it to ~/Activities')
    def checkin(self):
        enforce(self.args, 'Context is not specified')
        #context = self.args.pop(0)
        raise NotImplementedError()

    @application.command(
            'CONTEXT\n'
            'delete all implementations downloaded by "checkin" command')
    def checkout(self):
        enforce(self.args, 'Context is not specified')
        #context = self.args.pop(0)
        raise NotImplementedError()


# New defaults
application.debug.value = sugar.logger_level()

Option.seek('sugar-network')
Option.seek('sugar-network', [application.debug])

app = Application(
        name='sugar-network',
        description='Sugar Network client utility',
        epilog='See http://wiki.sugarlabs.org/go/Sugar_Network ' \
                 'for details.',
        where={
            'CONTEXT':
                'context GUID or name context should implement',
            'RESTRICTION':
                'particular context implementation in form of:\n' \
                        '=|>=|< VERSION',
            'ARGS':
                'arbitrary command-line arguments to pass as-is to ' \
                        'launching context implementation',
                },
        config_files=[
            '/etc/sweets.conf',
            '~/.config/sweets/config',
            sugar.profile_path('sweets.conf'),
            ],
        stop_args=['launch'])
app.start()