slimcoin-project / pacli

Simple CLI PeerAssets client (extended version).
GNU General Public License v3.0
0 stars 0 forks source link

token show with global name #200

Open buhtignew opened 1 week ago

buhtignew commented 1 week ago

Seems like token show LABEL usage mode works with the local labels only, specifically if I run token show ATTokenNotPoB for the deck that on my side doesn't have a local label I'm getting:

No entry was found for this label.

However the token show ATTokenNotPoB -i provides the same output of the corresponding token show f7b1af6d565898851878cb13c88bb52996a0a5380c4ea8803c248a69c7d00d82 -i command.

d5000 commented 3 days ago

Yes, the -i mode works different, it takes an ID, global or local label.

As it was an easy addition I added the possibility to show deck IDs entering the global label. If you only want to search in the local label list in the configuration file then you now have to add -l. Commit: fbb99a7.

Can be closed, does not really need testing.

buhtignew commented 1 day ago

It works on my side.

The only thing I haven't really got is the usage of the -l flag. Both token show LOCAL_LABEL and token show GLOBAL_LABEL work without the -l flag now, while the -l flag can't be used with any other flag except -d and -q. The only explanation I'm seeing to use it is, along with outputting the token's id, to check whether the label I'm using is the local one or not. Maybe it would make sense to suppress it?

By the way if the -i and the -l flag are used in the same command (for instance token show ATTokenNewSpec2_local -l -i) the following error message is being output:

  File "~/.local/bin/pacli", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "~/.local/lib/python3.12/site-packages/pacli/__main__.py", line 479, in main
    fire.Fire({
  File "~/.local/lib/python3.12/site-packages/fire/core.py", line 143, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/.local/lib/python3.12/site-packages/fire/core.py", line 477, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
                                ^^^^^^^^^^^^^^^^^^^^
  File "~/.local/lib/python3.12/site-packages/fire/core.py", line 693, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "~/.local/lib/python3.12/site-packages/pacli/extended_classes.py", line 978, in show
    return ei.run_command(self.__show, deckstr=_idstr, param=param, info=info, find=find, local=local, show_p2th=show_p2th, quiet=quiet, debug=debug)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/.local/lib/python3.12/site-packages/pacli/extended_interface.py", line 35, in run_command
    result = c(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^
  File "~/.local/lib/python3.12/site-packages/pacli/extended_classes.py", line 994, in __show
    deckinfo = eu.get_deckinfo(deckid, show_p2th)
                               ^^^^^^
UnboundLocalError: cannot access local variable 'deckid' where it is not associated with a value
d5000 commented 19 hours ago

The idea of the -l flag was indeed that if someone wants to know only if there's a local label, and otherwise output nothing (for example using it with -q in a script) then this would be needed, because all other options then search for the global name or ID if they exist.

I don't think it's a very important use case, but it doesn't harm either, and in scripts it can be useful.

The error you mentioned has been catched now, will simply output the red General Error as usually when flag combinations are wrong. Commit 8c26c4b.

EDIT: I changed my mind and have removed the -l option. The reason is that for scripts we have a much better option with config show LABEL -e deck which only accesses the config file.

EDIT2: I added another improvement: Now the -i or --info flag will show a more user friendly dictionary. The old info dict is now available with --rawinfo or -r.

Commit for the last changes is cbec860.

buhtignew commented 10 hours ago

I'm getting the following error if I run token show ATTokenNewSpec2_local -i:

~/.local/lib/python3.12/site-packages/pacli/extended_interface.py:224: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
  "Creation Time (UTC)" : str(datetime.datetime.utcfromtimestamp(int(deckinfo.get("issue_time")))),
Traceback (most recent call last):
  File "~/.local/bin/pacli", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "~/.local/lib/python3.12/site-packages/pacli/__main__.py", line 479, in main
    fire.Fire({
  File "~/.local/lib/python3.12/site-packages/fire/core.py", line 143, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/.local/lib/python3.12/site-packages/fire/core.py", line 477, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
                                ^^^^^^^^^^^^^^^^^^^^
  File "~/.local/lib/python3.12/site-packages/fire/core.py", line 693, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "~/.local/lib/python3.12/site-packages/pacli/extended_classes.py", line 979, in show
    return ei.run_command(self.__show, deckstr=_idstr, param=param, info=info, rawinfo=rawinfo, find=find, show_p2th=show_p2th, quiet=quiet, debug=debug)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/.local/lib/python3.12/site-packages/pacli/extended_interface.py", line 35, in run_command
    result = c(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^
  File "~/.local/lib/python3.12/site-packages/pacli/extended_classes.py", line 1002, in __show
    ei.print_deckinfo(deckinfo, quiet=quiet)
  File "~/.local/lib/python3.12/site-packages/pacli/extended_interface.py", line 231, in print_deckinfo
    if deckinfo["at_address"] == au.burn_address():
                                 ^^
NameError: name 'au' is not defined

_ I'm not able to check the commit 8c26c4b, since the -l flag was removed :-)