feat: cli tool
This commit is contained in:
		
							parent
							
								
									7738a3d497
								
							
						
					
					
						commit
						648653df59
					
				
					 3 changed files with 62 additions and 0 deletions
				
			
		
							
								
								
									
										5
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -1 +1,6 @@
 | 
			
		|||
book
 | 
			
		||||
.env
 | 
			
		||||
cache
 | 
			
		||||
.DS_Store
 | 
			
		||||
build
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										56
									
								
								cli.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								cli.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,56 @@
 | 
			
		|||
#! /usr/bin/env python
 | 
			
		||||
 | 
			
		||||
import argparse
 | 
			
		||||
import subprocess
 | 
			
		||||
import sys
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def build(args):
 | 
			
		||||
    parser = argparse.ArgumentParser(description='Compiling the documentation')
 | 
			
		||||
    parser.add_argument('-v', '--verbose', action='store_true', help='verbose mode')
 | 
			
		||||
    parser.add_argument('--update_issues', action='store_true', help='update issues')
 | 
			
		||||
    args = parser.parse_args(args)
 | 
			
		||||
    if args.verbose:
 | 
			
		||||
        print("build start")
 | 
			
		||||
    if args.update_issues:
 | 
			
		||||
        if args.verbose:
 | 
			
		||||
            print("get issues")
 | 
			
		||||
        p = subprocess.run(["deno", "run", "-A","tools/getIssue.ts", "--path","./build/issues.json"])
 | 
			
		||||
        p.check_returncode()
 | 
			
		||||
    if args.verbose:
 | 
			
		||||
        print("build issues")
 | 
			
		||||
    p = subprocess.run(["deno", "run", "-A","tools/printDocument.ts", "--overall", "--path", "./build/issues.json", "--outpath", "./build/overall.md"])
 | 
			
		||||
    p.check_returncode()
 | 
			
		||||
    p = subprocess.run(["deno", "run", "-A","tools/printDocument.ts", "--path", "./build/issues.json", "--outpath", "./build/specific.md"])
 | 
			
		||||
    p.check_returncode()
 | 
			
		||||
 | 
			
		||||
def help(_args):
 | 
			
		||||
    global commandList
 | 
			
		||||
    print("subcommands:")
 | 
			
		||||
    for command in commandList.keys():
 | 
			
		||||
        print("\t", command)
 | 
			
		||||
 | 
			
		||||
commandList = {
 | 
			
		||||
    'build': build,
 | 
			
		||||
    'help': help
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
    args = sys.argv
 | 
			
		||||
    if len(args) < 2:
 | 
			
		||||
        print("no subcommand", file=sys.stderr)
 | 
			
		||||
        help(args)
 | 
			
		||||
        return
 | 
			
		||||
    _command = args[0]
 | 
			
		||||
    subCommand = args[1]
 | 
			
		||||
    if subCommand not in commandList:
 | 
			
		||||
        print("Command not found", file=sys.stderr)
 | 
			
		||||
        help(args)
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
    args = args[2:]
 | 
			
		||||
    os.makedirs("build", exist_ok=True)
 | 
			
		||||
    commandList[subCommand](args)
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    main()
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
#! /usr/bin/env deno run --allow-net --allow-env
 | 
			
		||||
import {Issue} from "./githubType.ts";
 | 
			
		||||
import {parse} from "https://deno.land/std@0.135.0/flags/mod.ts";
 | 
			
		||||
import "https://deno.land/std@0.136.0/dotenv/load.ts";
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * get issue from github
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue