[cli] Update examples in documentation

pull/2/head
Daniel Van Der Maden 5 years ago
parent 142dede5e3
commit 7d28dd3f6f
  1. 31
      pyhmy/cli.py

@ -8,19 +8,17 @@ Example:
Below is a demo of how to import, manage keys, and interact with the CLI:: Below is a demo of how to import, manage keys, and interact with the CLI::
>>> from pyhmy import cli >>> from pyhmy import cli
>>> cli.single_call("hmy keys add test1") >>> cli.single_call("hmy keys add test1")
>>> addrs = cli.get_accounts_keystore() '**Important** write this seed phrase in a safe place, it is the only way to recover your account if you ever forget your password
>>> assert "test1" in addrs.keys() craft ... tobacco'
>>> check_addr = addrs["test1"] >>> cli.get_accounts_keystore()
>>> accounts_list = cli.get_accounts(check_addr) {'test1': 'one1aqfeed538xf7n0cfh60tjaeat7yw333pmj6sfu'}
>>> check_acc = accounts_list[0] >>> check_addr = cli.get_accounts_keystore()["test1"]
>>> assert check_acc == "test1" >>> cli.get_accounts(check_addr)
>>> raw_cli_keys_list_print = cli.single_call("hmy keys list", timeout=2) ['test1']
>>> assert check_addr in raw_cli_keys_list_print >>> cli.single_call("hmy keys list", timeout=2)
>>> assert check_acc in raw_cli_keys_list_print 'NAME \t\t ADDRESS\n\ntest1 \tone1aqfeed538xf7n0cfh60tjaeat7yw333pmj6sfu\n'
>>> assert addrs[check_acc] == check_addr >>> cli.get_accounts_keystore()
>>> cli.remove_address(check_addr) {}
>>> assert check_addr not in addrs.values()
>>> assert "test1" not in addrs.keys()
This module refers to `accounts` as the NAME/ALIAS of an `address` given to by the This module refers to `accounts` as the NAME/ALIAS of an `address` given to by the
CLI's account keystore. CLI's account keystore.
@ -31,13 +29,16 @@ binary that is used by this module can be changed with the `set_binary` function
Example: Example:
Below is a demo of how to set the CLI binary used by the module:: Below is a demo of how to set the CLI binary used by the module::
>>> from pyhmy import cli
>>> from pyhmy import util >>> from pyhmy import util
>>> import os >>> import os
>>> util.download_cli("test", replace=False) >>> util.download_cli("test", replace=False)
>>> new_path = os.getcwd() + "/bin/test" >>> new_path = os.getcwd() + "/bin/test"
>>> new_path
'/Users/danielvdm/go/src/github.com/harmony-one/pyhmy/bin/test'
>>> from pyhmy import cli
>>> cli.set_binary(new_path) >>> cli.set_binary(new_path)
>>> assert new_path == cli.get_binary_path() >>> cli.get_binary_path()
'/Users/danielvdm/go/src/github.com/harmony-one/pyhmy/bin/test'
For more details, reference the documentation here: TODO gitbook docs For more details, reference the documentation here: TODO gitbook docs
""" """

Loading…
Cancel
Save