@@ -65,16 +65,36 @@ def init():
6565
6666
6767@configure_app .command ("gen-keys" )
68- def gen_keys ():
69- """秘密鍵とCSRを api_key_dir に生成します"""
70- org = typer .prompt ("🔐 組織名を入力してください(例: MyCompany)" ).strip ()
68+ def gen_keys (
69+ org_name : str = typer .Option (None , help = "Organization Name (CN/O)" ),
70+ key_type : str = typer .Option (
71+ None , "--key-type" , help = "Key type: rsa:2048, rsa:4096, ed25519"
72+ ),
73+ ):
74+ """Generate a pair of secret key and the CSR key"""
75+ org = typer .prompt ("🔐 Organization Name:" ).strip ()
7176 if not org :
72- typer .secho ("❌ 組織名は必須です。処理を中止します。 " , fg = typer .colors .RED )
77+ typer .secho ("❌ Organisztion Name is required. " , fg = typer .colors .RED )
7378 raise typer .Exit (code = 1 )
79+ if not key_type :
80+ typer .echo ("Select Key Type:" )
81+ typer .echo ("[1] rsa:2048" )
82+ typer .echo ("[2] rsa:4096 (default)" )
83+ typer .echo ("[3] ed25519" )
84+ choice = typer .prompt ("Enter number (or 'y' for default)" ).strip ().lower ()
85+ if choice in ("" , "y" , "2" ):
86+ key_type = "rsa:4096"
87+ elif choice == "1" :
88+ key_type = "rsa:2048"
89+ elif choice == "3" :
90+ key_type = "ed25519"
91+ else :
92+ typer .secho ("❌ Invalid choice." , fg = typer .colors .RED )
93+ raise typer .Exit (code = 1 )
7494
75- key_path , csr_path = generate_key_and_csr (org )
76- typer .secho (f"✅ 秘密鍵 : { key_path } " , fg = typer .colors .GREEN )
77- typer .secho (f"✅ CSR : { csr_path } " , fg = typer .colors .GREEN )
95+ key_path , csr_path = generate_key_and_csr (org_name , key_type )
96+ typer .secho (f"✅ Private Key : { key_path } " , fg = typer .colors .GREEN )
97+ typer .secho (f"✅ CSR Key : { csr_path } " , fg = typer .colors .GREEN )
7898
7999
80100@configure_app .command ("validate" )
0 commit comments