lotus/scripts/generate-lotus-cli.py
Phi-rjan b446a39a40
build: release: v1.27.1-rc2 (#12101)
* fix: ci: do not use deprecated --debug goreleaser flag (#12086)

* chore: deals: remove forgotten graphsync references (#12084)

* chore: types: remove more items forgotten after markets (#12095)

* chore: cleanup: remove more items forgotten after markets

* .gz somehow reappeared after https://github.com/filecoin-project/lotus/pull/11625

* fix: ETH RPC API: ETH Call should use the parent state root of the subsequent tipset (#11905)

* fix eth call

* tests

* changes as per review

* changes as per review

* Update node/impl/full/eth.go

Co-authored-by: Rod Vagg <rod@vagg.org>

* fix as per review

---------

Co-authored-by: Rod Vagg <rod@vagg.org>

* Update changelog to RC2

Update changelog to RC2

* Make gen / make docsgen-cli

Make gen / make docsgen-cli

* chore: api: the Net API/CLI now remains only on daemon

The only part of this repository that does lp2p is now lotus-daemon

Remove the CommonNet type, used exclusively bu the CLI stack

Adjust the rest of struct-memebership to match what went where

End result best seen in diff of `documentation/en/api-v0-methods-miner.md`

* Update changelog

Update changelog

* fix: events: sqlite db improvements (#12090)

* fix: events: sqlite db improvements

* fix unclosed multi-row query
* tune options to limit wal growth

Ref: https://github.com/filecoin-project/lotus/issues/12089

* fix: events: use correct context for CollectEvents transaction

* fix: events: close prepared read statement

* fix: events: close initial query; handle lint failures

* Update CHANGELOG.md

---------

Co-authored-by: Piotr Galar <piotr.galar@gmail.com>
Co-authored-by: Peter Rabbitson <ribasushi@protocol.ai>
Co-authored-by: Aarsh Shah <aarshkshah1992@gmail.com>
Co-authored-by: Rod Vagg <rod@vagg.org>
Co-authored-by: Peter Rabbitson <ribasushi@leporine.io>
2024-06-19 10:28:57 -04:00

61 lines
2.3 KiB
Python

#!/usr/bin/env python
# Generate lotus command lines documents as text and markdown in folder "lotus/documentation/en".
# Python 3
import os
def generate_lotus_cli(prog):
output_folder = 'documentation/en'
md_file = open('%s/cli-%s.md' % (output_folder, prog), 'w') # set the name of md output
def get_cmd_recursively(cur_cmd):
depth = cur_cmd.count(' ')
md_file.writelines(('\n' * min(depth, 1)) + ('#' * depth) + '# ' + cur_cmd[2:] + '\n')
cmd_flag = False
print('> ' + cur_cmd)
cmd_help_output = os.popen(cur_cmd + ' -h')
cmd_help_output_lines = cmd_help_output.readlines()
md_file.writelines('```\n')
md_file.writelines(cmd_help_output_lines)
md_file.writelines('```\n')
for line in cmd_help_output_lines:
try:
line = line.strip()
if line == 'COMMANDS:':
cmd_flag = True
if cmd_flag is True and line == '':
cmd_flag = False
if cmd_flag is True and line[-1] != ':' and 'help, h' not in line:
gap_pos = None
sub_cmd = line.split(',')[0].strip() # only take the first sub-command before the comma
if ' ' in sub_cmd:
gap_pos = sub_cmd.index(' ')
sub_cmd = cur_cmd + ' ' + sub_cmd[:gap_pos]
get_cmd_recursively(sub_cmd)
except Exception as e:
print('Fail to deal with "%s" with error:\n%s' % (line, e))
get_cmd_recursively('./' + prog)
md_file.close()
if __name__ == "__main__":
# When --help is generated one needs to make sure none of the
# urfave-cli `EnvVars:` defaults get triggered
# Unset everything we can find via: grep -ho 'EnvVars:.*' -r * | sort -u
for e in [ "LOTUS_PATH", "LOTUS_MINER_PATH", "LOTUS_STORAGE_PATH", "LOTUS_WORKER_PATH", "WORKER_PATH", "LOTUS_PANIC_REPORT_PATH", "WALLET_PATH" ]:
os.environ.pop(e, None)
# Set env var telling the binaries that we're generating docs
os.putenv("LOTUS_DOCS_GENERATION", "1")
os.putenv("LOTUS_VERSION_IGNORE_COMMIT", "1")
generate_lotus_cli('lotus')
generate_lotus_cli('lotus-miner')
generate_lotus_cli('lotus-worker')