Coverage for gws-app/gws/server/cli.py: 0%

36 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-10-16 23:09 +0200

1"""Command-line server commands.""" 

2 

3from typing import Optional 

4 

5import gws 

6 

7from . import control 

8 

9 

10class Params(gws.CliParams): 

11 """Parameters for server commands.""" 

12 config: Optional[str] 

13 """Configuration file.""" 

14 manifest: Optional[str] 

15 """Manifest file.""" 

16 

17 

18class ConfigTestParams(gws.CliParams): 

19 """Parameters for the config test command.""" 

20 config: Optional[str] 

21 """Configuration file.""" 

22 manifest: Optional[str] 

23 """Manifest file.""" 

24 dirs: Optional[str] 

25 """Directories to watch for changes.""" 

26 watch: Optional[bool] 

27 """Watch mode.""" 

28 parse: Optional[bool] 

29 """Only parse the config.""" 

30 

31 

32gws.ext.new.cli('server') 

33 

34 

35class Object(gws.Node): 

36 """Server command-line interface object.""" 

37 

38 @gws.ext.command.cli('serverStart') 

39 def do_start(self, p: Params): 

40 """Configure and start the server.""" 

41 

42 control.start(p.manifest, p.config) 

43 

44 @gws.ext.command.cli('serverReload') 

45 def do_reload(self, p: Params): 

46 """Restart the server.""" 

47 

48 control.reload_all() 

49 

50 @gws.ext.command.cli('serverReconfigure') 

51 def do_reconfigure(self, p: Params): 

52 """Reconfigure and restart the server.""" 

53 

54 control.reconfigure(p.manifest, p.config) 

55 

56 @gws.ext.command.cli('serverConfigure') 

57 def do_configure(self, p: Params): 

58 """Configure the server, but do not restart.""" 

59 

60 control.configure_and_store(p.manifest, p.config) 

61 

62 @gws.ext.command.cli('serverConfigtest') 

63 def do_configtest(self, p: ConfigTestParams): 

64 """Test the configuration.""" 

65 

66 control.config_test( 

67 p.manifest, 

68 p.config, 

69 p.dirs, 

70 with_parse_only=p.parse, 

71 with_watch=p.watch, 

72 )