Coverage for sources/emcdproj/website/cli.py: 52%
25 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-11 21:41 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-11 21:41 +0000
1# vim: set filetype=python fileencoding=utf-8:
2# -*- coding: utf-8 -*-
4#============================================================================#
5# #
6# Licensed under the Apache License, Version 2.0 (the "License"); #
7# you may not use this file except in compliance with the License. #
8# You may obtain a copy of the License at #
9# #
10# http://www.apache.org/licenses/LICENSE-2.0 #
11# #
12# Unless required by applicable law or agreed to in writing, software #
13# distributed under the License is distributed on an "AS IS" BASIS, #
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
15# See the License for the specific language governing permissions and #
16# limitations under the License. #
17# #
18#============================================================================#
21''' Command-line interface for website maintenance. '''
24from . import __
25from . import publication as _publication
28class SurveyCommand(
29 __.interfaces.CliCommand, decorators = ( __.standard_tyro_class, ),
30):
31 ''' Surveys release versions published in static website. '''
33 use_extant: __.typx.Annotated[
34 bool,
35 __.typx.Doc( ''' Fetch publication branch and use tarball. ''' ),
36 ] = False
38 async def __call__(
39 self, auxdata: __.Globals, display: __.interfaces.ConsoleDisplay
40 ) -> None:
41 _publication.survey( auxdata, use_extant = self.use_extant )
44class UpdateCommand(
45 __.interfaces.CliCommand, decorators = ( __.standard_tyro_class, ),
46):
47 ''' Updates static website for particular release version. '''
49 version: __.typx.Annotated[
50 str,
51 __.typx.Doc( ''' Release version to update. ''' ),
52 __.tyro.conf.Positional,
53 ]
55 use_extant: __.typx.Annotated[
56 bool,
57 __.typx.Doc( ''' Fetch publication branch and use tarball. ''' ),
58 ] = False
60 production: __.typx.Annotated[
61 bool,
62 __.typx.Doc( ''' Update publication branch with new tarball.
63 Implies --use-extant to prevent data loss. ''' ),
64 ] = False
66 configuration: __.typx.Annotated[
67 str,
68 __.typx.Doc( ''' Track configuration TOML file for publication. ''' ),
69 ] = ''
71 legacy_inventory: __.typx.Annotated[
72 str,
73 __.typx.Doc( ''' Legacy-link inventory TOML file for validation. ''' ),
74 ] = ''
76 async def __call__(
77 self, auxdata: __.Globals, display: __.interfaces.ConsoleDisplay
78 ) -> None:
79 configuration: __.Absential[ __.Path | str ] = __.absent
80 if self.configuration:
81 configuration = self.configuration
82 inventory: __.Absential[ __.Path ] = __.absent
83 if self.legacy_inventory:
84 inventory = __.Path( self.legacy_inventory )
85 _publication.update(
86 auxdata, self.version,
87 use_extant = self.use_extant,
88 production = self.production,
89 configuration = configuration,
90 legacy_inventory = inventory )
93class CommandDispatcher(
94 __.interfaces.CliCommand, decorators = ( __.standard_tyro_class, ),
95):
96 ''' Dispatches commands for static website maintenance. '''
98 command: __.typx.Union[
99 __.typx.Annotated[
100 SurveyCommand,
101 __.tyro.conf.subcommand( 'survey', prefix_name = False ),
102 ],
103 __.typx.Annotated[
104 UpdateCommand,
105 __.tyro.conf.subcommand( 'update', prefix_name = False ),
106 ],
107 ]
109 async def __call__(
110 self, auxdata: __.Globals, display: __.interfaces.ConsoleDisplay
111 ) -> None:
112 ictr( 1 )( self.command )
113 await self.command( auxdata = auxdata, display = display )