@@ -80,9 +80,14 @@ def run(self, manager, args):
8080 try :
8181 if manager .sessions and args .variable == "db" :
8282 raise ValueError ("cannot change database with running session" )
83- manager .config .set (
84- args .variable , args .value , getattr (args , "global" )
85- )
83+ if args .variable in manager .config :
84+ manager .config .set (
85+ args .variable , args .value , getattr (args , "global" )
86+ )
87+ else :
88+ console .log (
89+ f"[red]error[/red]: invalid choice { repr (args .variable )} "
90+ )
8691 if args .variable == "db" :
8792 # Ensure the database is re-opened, if it was already
8893 manager .open_database ()
@@ -95,10 +100,15 @@ def run(self, manager, args):
95100 except ValueError as exc :
96101 console .log (f"[red]error[/red]: { exc } " )
97102 elif args .variable is not None :
98- value = manager .config [args .variable ]
99- console .print (
100- f" [cyan]{ args .variable } [/cyan] = [yellow]{ repr (value )} [/yellow]"
101- )
103+ if args .variable in manager .config :
104+ value = manager .config [args .variable ]
105+ console .print (
106+ f" [cyan]{ args .variable } [/cyan] = [yellow]{ repr (value )} [/yellow]"
107+ )
108+ else :
109+ console .log (
110+ f"[red]error[/red]: invalid choice { repr (args .variable )} "
111+ )
102112 else :
103113 for name in manager .config :
104114 value = manager .config [name ]
0 commit comments