@ -411,7 +411,8 @@ def label_edit(issue):
@issue.command ( )
@pass_issue
def debug ( issue ) :
@pass_client
def debug ( client , issue ) :
import IPython
IPython . embed ( )
@ -465,8 +466,68 @@ def show(client, issue):
for i , comment in enumerate ( issue . fields . comment . comments ) :
if i != 0 :
print ( ' ' )
print ( f " { comment . created } - { comment . author } ")
print ( f " { comment . created } - { comment . author } - { comment . id } ")
body = indent ( ' \n ' . join ( wrap ( comment . body , replace_whitespace = False ) ) , ' ' * 4 )
print ( body )
print ( ' ' )
@issue.group ( )
def comment ( ) :
pass
@comment.command ( ' create ' )
@pass_issue
@pass_client
def comment_create ( client , issue ) :
""" Create a comment on the issue """
# TODO add some help text for the syntax in the description
# TODO add all issue info to the description, so we can autocomplete in the
# editor
text = prompt ( f " Comment text to add as new comment to { issue . key } " )
client . add_comment ( issue . key , text )
def get_comment ( client , issue , comment_id ) :
if not comment_id :
from clintermission import cli_select_item
options = [ ]
for comment in issue . fields . comment . comments :
# TODO make this roughly terminal width or add a shorten() method
# with … at the end
body = comment . body . replace ( ' \n ' , ' ' ) [ : 64 ]
options . append ( ( f " { comment . created } - { comment . author } - { body } " , comment . id ) )
_ , comment_id = cli_select_item ( options )
return client . comment ( issue . key , comment_id , expand = [ ' body ' ] )
@comment.command ( ' edit ' )
@click.argument ( ' comment_id ' , required = False )
@pass_issue
@pass_client
def comment_edit ( client , issue , comment_id ) :
""" Edit the text of an issues comment """
comment = get_comment ( client , issue , comment_id )
text = prompt ( f " Comment text to set as new body for comment { comment_id } on { issue . key } " ,
initial_content = comment . body )
if text == comment . body :
print ( " No changes. Aborting. " )
return
comment . update ( body = text )
@comment.command ( ' delete ' )
@click.argument ( ' comment_id ' , required = False )
@pass_issue
@pass_client
def comment_delete ( client , issue , comment_id ) :
comment = get_comment ( client , issue , comment_id )
# TODO print formatted comment for verification
click . confirm ( " Do you really want to delete this ^ ? " , abort = True )
comment . delete ( )