def pitz_add_milestone(): p = setup_options() p.add_option('-t', '--title', help='Milestone title') options, args = p.parse_args() if options.version: print_version() return pitzdir = Project.find_pitzdir(options.pitzdir) pidfile = write_pidfile_or_die(pitzdir) proj = Project.from_pitzdir(pitzdir) proj.find_me() m = Milestone( proj, title=options.title or raw_input("Milestone title: ").strip(), description=clepy.edit_with_editor( '# Milestone description goes here'), reached=Milestone.choose_from_allowed_values('reached', False), ) proj.append(m) print("Added %s to the project." % m.summarized_view) proj.save_entities_to_yaml_files() os.remove(pidfile)
def handle_proj(self, p, options, args, proj): default_milestone = Milestone(proj, title='unscheduled') default_estimate = Estimate(proj, title='not estimated') default_owner = Person(proj, title='no owner') default_tags = list() t = Task( proj, title=options.title or raw_input("Task title: ").strip(), description=( '' if options.no_description else clepy.edit_with_editor('# Task description goes here')), status=Status(proj, title='unstarted'), milestone=default_milestone if options.use_defaults \ else Milestone.choose_from_already_instantiated( default_milestone, predicate=lambda m: not m.reached), estimate=default_estimate if options.use_defaults \ else Estimate.choose_from_already_instantiated(default_estimate), owner=default_owner if options.use_defaults \ else Person.choose_from_already_instantiated(default_owner), tags=default_tags if options.use_defaults \ else Tag.choose_many_from_already_instantiated(), ) proj.append(t) print("Added %r to the project." % t)