devanshkv / argmark

Convert argparse based bin scripts to markdown documents
https://pypi.org/project/argmark/
MIT License
10 stars 4 forks source link

Argmark not creating markdown #6

Open Relyte opened 1 year ago

Relyte commented 1 year ago

I ran argmark with the following command against this repo: https://github.com/Relyte/cosmos-multivote

argmark -f multi-vote.py

It gave no output against that file. I did get it working by creating a new file (multi-vote-copy.py) that had the following contents:

import argparse

parser = argparse.ArgumentParser(
    prog="multi-vote.py",
    description="Create json file for multiple votes in a single transaction",
    formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument(
    "--denom",
    dest="denom",
    required=False,
    default="ukuji",
    help="native chain denom",
)
parser.add_argument(
    "--daemon",
    dest="daemon",
    required=False,
    default="kujirad",
    help="daemon for sending tx",
)
parser.add_argument(
    "-c",
    "--chain_id",
    dest="chain_id",
    required=False,
    default="cosmoshub-4",
    help="Chain ID (ex. kaiyo-1)",
)
parser.add_argument(
    "-e",
    "--endpoint",
    dest="endpoint",
    required=False,
    help="RPC endpoint",
)
parser.add_argument(
    "-m",
    "--memo",
    dest="memo",
    help="Memo to send with votes",
)
parser.add_argument(
    "-k",
    "--keyname",
    dest="keyname",
    required=False,
    help="Wallet to vote from",
)
parser.add_argument(
    "-b",
    "--keyringbackend",
    dest="keyringbackend",
    default="test",
    required=False,
    help="Keyring Backend type",
)
parser.add_argument(
    "-s",
    "--send_address",
    dest="send_address",
    required=True,
    help="Address to vote from",
)
parser.add_argument(
    "-v",
    "--vote",
    dest="vote",
    action="append",
    required=True,
    help="Votes in the format of `proposal_id:vote_option` (eg: 110:no 111:yes 112:veto 113:abstain)",
)
parser.add_argument(
    "-d",
    "--dry-run",
    dest="dryrun",
    default=False,
    required=False,
    action="store_true",
    help="Do not sign or broadcast tx, just prepare the .json file",
)

args=parser.parse_args()

When run against this file it did properly create the markdown file. I'm assuming the issue is due to my argparse arguments being defined in the parseArgs function as opposed to main.

In case it is helpful, I ran argmark with verbose enabled against the multi-vote.py file and got the following output:

2022-12-27 16:17:22,874 - gen_help -root - DEBUG - import argparse

import json

from subprocess import run

from time import sleep, strftime

from getpass import getpass

def parseArgs():

    """Parse and return argparse arguments"""

    parser = argparse.ArgumentParser(

        prog="multi-vote.py",

        description="Create json file for multiple votes in a single transaction",

        formatter_class=argparse.ArgumentDefaultsHelpFormatter,

    )

    parser.add_argument(

        "--denom",

        dest="denom",

        required=False,

        default="ukuji",

        help="native chain denom",

    )

    parser.add_argument(

        "--daemon",

        dest="daemon",

        required=False,

        default="kujirad",

        help="daemon for sending tx",

    )

    parser.add_argument(

        "-c",

        "--chain_id",

        dest="chain_id",

        required=False,

        default="cosmoshub-4",

        help="Chain ID (ex. kaiyo-1)",

    )

    parser.add_argument(

        "-e",

        "--endpoint",

        dest="endpoint",

        required=False,

        help="RPC endpoint",

    )

    parser.add_argument(

        "-m",

        "--memo",

        dest="memo",

        help="Memo to send with votes",

    )

    parser.add_argument(

        "-k",

        "--keyname",

        dest="keyname",

        required=False,

        help="Wallet to vote from",

    )

    parser.add_argument(

        "-b",

        "--keyringbackend",

        dest="keyringbackend",

        default="test",

        required=False,

        help="Keyring Backend type",

    )

    parser.add_argument(

        "-s",

        "--send_address",

        dest="send_address",

        required=True,

        help="Address to vote from",

    )

    parser.add_argument(

        "-v",

        "--vote",

        dest="vote",

        action="append",

        required=True,

        help="Votes in the format of `proposal_id:vote_option` (eg: 110:no 111:yes 112:veto 113:abstain)",

    )

    parser.add_argument(

        "-d",

        "--dry-run",

        dest="dryrun",

        default=False,

        required=False,

        action="store_true",

        help="Do not sign or broadcast tx, just prepare the .json file",

    )

    import argmark
    argmark.md_help(parser)
devanshkv commented 7 months ago

@lennertvandevelde adding you as a collaborator.