@cli.command(short_help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', type=click.Path(dir_okay=False),<EOL>help="<STR_LIT>")<EOL>@click.argument('<STR_LIT>', default=<NUM_LIT:0>, type=click.IntRange(min=<NUM_LIT:0>))<EOL>@click.pass_context<EOL>def edit(ctx, file_to_edit, previous_file):
timesheet_collection = None<EOL>autofill = not bool(file_to_edit) and previous_file == <NUM_LIT:0><EOL>if not file_to_edit:<EOL><INDENT>file_to_edit = ctx.obj['<STR_LIT>'].get_entries_file_path(False)<EOL><DEDENT>if autofill:<EOL><INDENT>try:<EOL><INDENT>timesheet_collection = get_timesheet_collection_for_context(<EOL>ctx, file_to_edit<EOL>)<EOL><DEDENT>except ParseError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>t = timesheet_collection.latest()<EOL>if ctx.obj['<STR_LIT>']['<STR_LIT>'] != Settings.AUTO_ADD_OPTIONS['<STR_LIT>']:<EOL><INDENT>auto_fill_days = ctx.obj['<STR_LIT>']['<STR_LIT>']<EOL>if auto_fill_days:<EOL><INDENT>t.prefill(auto_fill_days, limit=None)<EOL><DEDENT>t.save()<EOL><DEDENT><DEDENT><DEDENT>timesheet_files = list(reversed(TimesheetCollection.get_files(file_to_edit, previous_file)))<EOL>if previous_file >= len(timesheet_files):<EOL><INDENT>ctx.fail("<STR_LIT>" % file_to_edit)<EOL><DEDENT>expanded_file_to_edit = list(timesheet_files)[previous_file]<EOL>editor = ctx.obj['<STR_LIT>']['<STR_LIT>']<EOL>edit_kwargs = {<EOL>'<STR_LIT:filename>': expanded_file_to_edit,<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}<EOL>if editor:<EOL><INDENT>edit_kwargs['<STR_LIT>'] = editor<EOL><DEDENT>click.edit(**edit_kwargs)<EOL>try:<EOL><INDENT>timesheet_collection = get_timesheet_collection_for_context(<EOL>ctx, file_to_edit<EOL>)<EOL><DEDENT>except ParseError as e:<EOL><INDENT>ctx.obj['<STR_LIT>'].err(e)<EOL><DEDENT>else:<EOL><INDENT>ctx.obj['<STR_LIT>'].show_status(<EOL>timesheet_collection.entries.filter(regroup=True, pushed=False)<EOL>)<EOL><DEDENT>
Opens your timesheet file in your favourite editor.

The PREVIOUS_FILE argument can be used to specify which nth previous file
to edit. A value of 1 will edit the previous file, 2 will edit the
second-previous file, etc.