MCPcopy Create free account
hub / github.com/Breakthrough/PySceneDetect / Command

Class Command

scenedetect/_cli/__init__.py:105–144  ·  view source on GitHub ↗

Custom formatting for commands.

Source from the content-addressed store, hash-verified

103
104
105class Command(click.Command):
106 """Custom formatting for commands."""
107
108 def format_help(self, ctx: click.Context, formatter: click.HelpFormatter) -> None:
109 """Writes the help into the formatter if it exists."""
110 if ctx.parent:
111 formatter.write(click.style(f"`{ctx.command.name}` Command", fg="cyan"))
112 formatter.write_paragraph()
113 formatter.write(click.style(LINE_SEPARATOR, fg="cyan"))
114 formatter.write_paragraph()
115 else:
116 formatter.write(click.style(LINE_SEPARATOR, fg="yellow"))
117 formatter.write_paragraph()
118 formatter.write(click.style("PySceneDetect Help", fg="yellow"))
119 formatter.write_paragraph()
120 formatter.write(click.style(LINE_SEPARATOR, fg="yellow"))
121 formatter.write_paragraph()
122
123 self.format_usage(ctx, formatter)
124 self.format_help_text(ctx, formatter)
125 self.format_options(ctx, formatter)
126 self.format_epilog(ctx, formatter)
127
128 def format_help_text(self, ctx: click.Context, formatter: click.HelpFormatter) -> None:
129 """Writes the help text to the formatter if it exists."""
130 if self.help:
131 base_command = ctx.parent.info_name if ctx.parent is not None else ctx.info_name
132 formatted_help = self.help.format(
133 scenedetect=base_command, scenedetect_with_video=f"{base_command} -i video.mp4"
134 )
135 text = inspect.cleandoc(formatted_help).partition("\f")[0]
136 formatter.write_paragraph()
137 formatter.write_text(text)
138
139 def format_epilog(self, ctx: click.Context, formatter: click.HelpFormatter) -> None:
140 """Writes the epilog into the formatter if it exists."""
141 if self.epilog:
142 epilog = inspect.cleandoc(self.epilog)
143 formatter.write_paragraph()
144 formatter.write_text(epilog)
145
146
147class CommandGroup(Command, click.Group):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected