29
28
from gettext import gettext as _
32
def pre_create(template, project_dir, command_args):
31
def pre_create(command_template, project_template, project_dir, command_args):
33
32
"""Create the project directory before create command call"""
35
34
if len(command_args) < 1:
36
print _("ERROR: Create command must be followed by a template and a project path")
35
print _("Create command must be followed by a template and a project path.\nUsage: quickly create <template> <project_name>")
39
38
path_and_project = command_args[0].split('/')
40
39
project_name = path_and_project[-1]
50
49
# check that project name follow quickly rules and reformat it.
51
quickly_project_name = templatetools.quickly_name(project_name)
51
project_name = templatetools.quickly_name(project_name)
52
except templatetools.bad_project_name, e:
53
56
#bail if the name if taken
54
57
if os.path.exists(project_name):
58
61
#create directory and template file
59
62
print _("Creating project directory %s" % project_name)
60
63
os.mkdir(project_name)
61
print _("Directory %s created\n" % project_name)
63
65
# creating quickly file
64
configurationhandler.project_config['format'] = quicklyconfig.__version__
65
configurationhandler.project_config['project'] = quickly_project_name
66
configurationhandler.project_config['template'] = template
66
configurationhandler.project_config['version'] = quicklyconfig.__version__
67
configurationhandler.project_config['project'] = project_name
68
configurationhandler.project_config['template'] = project_template
67
69
configurationhandler.saveConfig(config_file_path=project_name)
69
71
os.chdir(project_name)
73
def commands(template, project_dir, command_args, shell_completion=False):
75
def commands(project_template, project_dir, command_args, shell_completion=False):
74
76
"""List all commands ordered by templates"""
76
78
# We have nothing for this
91
def getstarted(template, project_dir, command_args, shell_completion=False):
93
def getstarted(project_template, project_dir, command_args, shell_completion=False):
92
94
""" Give some getstarted advice"""
94
96
# We have nothing for this
99
101
Welcome to quickly!
100
102
-------------------------------
102
You can create a project in executing 'quickly create <template_name> <your project>'.
105
Example with ubuntu-project template:
106
1. create a Ubuntu Project and run the tutorial:
107
$ quickly create ubuntu-project foo
104
You can create a project by executing 'quickly create <template_name> <your project>'.
106
Example with ubuntu-application template:
107
1. create an ubuntu application and run the tutorial:
108
$ quickly create ubuntu-application foo
109
110
$ quickly tutorial
111
112
2. You can also try:
115
Use bash completion to get every available commands
117
3. How to play with package and release:
119
optional, but recommended to build first your package locally:
116
Use bash completion to get every available command
118
3. How to play with a package and release it:
120
Optional (but recommended): build your package locally:
120
121
$ quickly package
122
BE WARNED: the two following commands will connect to Launchpad. You need at least having a Launchpad account and an opened ppa.
123
You need also for quickly release a project where you can bind your work with.
123
BE WARNED: the two following commands will connect to Launchpad. Make sure that you have a Launchpad account and a PPA! You can find out more about setting up a Launchpad account and Launchpad features at https://launchpad.net/
124
124
$ quickly release or $ quickly share
129
def help(template, project_dir, command_args, shell_completion=False):
129
def help(project_template, project_dir, command_args, shell_completion=False):
130
130
"""Get help from commands"""
132
132
# We have nothing for this
136
136
if len(command_args) > 0:
137
137
command_name = command_args[0]
139
print _("ERROR: No command provided to help command")
139
print _("No command provided to help command.\nUsage is: quickly help [template] <command>")
142
template = project_template
142
143
if template is None:
143
144
template = "builtins"
145
command = commands_module.get_command_by_criteria(name=command_name, template=template)[0]
146
command = commands_module.get_commands_by_criteria(name=command_name, template=project_template)[0]
146
147
except IndexError:
147
148
# check if a builtin commands corresponds
148
149
template = "builtins"
150
command = commands_module.get_command_by_criteria(name=command_name, template=template)[0]
151
command = commands_module.get_commands_by_criteria(name=command_name, template=template)[0]
151
152
except IndexError:
152
153
# there is really not such command
153
154
if template == "builtins":
154
155
# to help the user, we can search if this command_name corresponds to a command in a template
155
list_possible_commands = commands_module.get_command_by_criteria(name=command_name, followed_by_template=True)
156
list_possible_commands = commands_module.get_commands_by_criteria(name=command_name, followed_by_template=True)
156
157
if list_possible_commands:
157
print _("ERROR: help command must be followed by a template name for getting help from templates commands like %s." % command_name)
158
print _("Candidates template are: %s") % ", ".join([command.template for command in list_possible_commands])
158
proposed_templates = []
159
for template in commands_module.get_all_templates():
161
commands_module.get_all_commands()[template][command_name]
162
proposed_templates.append(template)
165
print _("help command must be followed by a template name for getting help from templates commands like %s.\nUsage is: quickly help [template] <command>" % command_name)
166
print _("Candidates template are: %s") % ", ".join(proposed_templates)
160
169
print _("ERROR: No %s command found.") % command_name
165
174
return(command.help(project_dir, command_args))
168
def quickly(template, project_dir, command_args, shell_completion=False):
177
def quickly(project_template, project_dir, command_args, shell_completion=False):
169
178
"""Create a new quickly template from an existing one"""
171
180
# We have nothing for this
175
184
if len(command_args) < 1:
176
print _("ERROR: Quickly command must be followed by a template and a template destination path")
185
print _("Quickly command must be followed by a template and a template destination path\nUsage is: quickly quickly [origin_template] destination_template")
179
188
destination_path = os.path.expanduser("~/quickly-templates/")
180
189
# create ~/quickly-templates/ if needed
189
198
if not os.path.exists(template_destination_path):
190
print _("Copy %s to create new %s template") % (template, template_destination_path)
199
print _("Copy %s to create new %s template") % (project_template, template_destination_path)
193
template_source_path = tools.get_template_directory(template)
194
except (tools.no_template_path_not_found, e):
202
template_source_path = tools.get_template_directory(project_template)
203
except tools.template_path_not_found, e:
206
except tools.template_not_found, e: