File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed
src/aleph_client/commands Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ classifiers = [
2424]
2525
2626dependencies = [
27- " aleph-sdk-python>=1.0.0 ,<2" ,
27+ " aleph-sdk-python>=1.0.1 ,<2" ,
2828 " setuptools>=65.5.0" ,
2929 " aleph-message>=0.4.9" ,
3030 " aiohttp==3.9.5" ,
Original file line number Diff line number Diff line change 2121from aleph_message .models import AlephMessage , ProgramMessage
2222from aleph_message .models .base import MessageType
2323from aleph_message .models .item_hash import ItemHash
24+ from aleph_message .status import MessageStatus
2425
2526from aleph_client .commands import help_strings
2627from aleph_client .commands .utils import (
2728 colorful_json ,
2829 colorful_message_json ,
30+ colorized_status ,
2931 input_multiline ,
3032 setup_logging ,
3133 str_to_datetime ,
@@ -41,8 +43,13 @@ async def get(
4143 item_hash : str = typer .Argument (..., help = "Item hash of the message" ),
4244):
4345 async with AlephHttpClient (api_server = sdk_settings .API_HOST ) as client :
44- message : AlephMessage = await client .get_message (item_hash = ItemHash (item_hash ))
45- typer .echo (colorful_message_json (message ))
46+ message , status = await client .get_message (item_hash = ItemHash (item_hash ), with_status = True )
47+ typer .echo (f"Message Status: { colorized_status (status )} " )
48+ if status == MessageStatus .REJECTED :
49+ reason = await client .get_message_error (item_hash = ItemHash (item_hash ))
50+ typer .echo (colorful_json (json .dumps (reason , indent = 4 )))
51+ else :
52+ typer .echo (colorful_message_json (message ))
4653
4754
4855@app .command ()
Original file line number Diff line number Diff line change 1313from aleph .sdk .conf import settings as sdk_settings
1414from aleph .sdk .types import GenericMessage
1515from aleph_message .models import ItemHash
16+ from aleph_message .status import MessageStatus
1617from pygments import highlight
1718from pygments .formatters .terminal256 import Terminal256Formatter
1819from pygments .lexers import JsonLexer
@@ -33,6 +34,18 @@ def colorful_json(obj: str):
3334 )
3435
3536
37+ def colorized_status (status : MessageStatus ) -> str :
38+ """Return a colored status string based on its value."""
39+ status_colors = {
40+ MessageStatus .REJECTED : typer .colors .RED ,
41+ MessageStatus .PROCESSED : typer .colors .GREEN ,
42+ MessageStatus .PENDING : typer .colors .YELLOW ,
43+ MessageStatus .FORGOTTEN : typer .colors .BRIGHT_BLACK ,
44+ }
45+ color = status_colors .get (status , typer .colors .WHITE )
46+ return typer .style (status , fg = color , bold = True )
47+
48+
3649def colorful_message_json (message : GenericMessage ):
3750 """Render a message in JSON with colors."""
3851 return colorful_json (message .json (sort_keys = True , indent = 4 ))
You can’t perform that action at this time.
0 commit comments