Skip to content

Commit dd7f619

Browse files
committed
Better markdown generator for scrambles and cube display
1 parent 56f774c commit dd7f619

3 files changed

Lines changed: 41 additions & 11 deletions

File tree

term_timer/arguments.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,22 @@ def scramble_arguments(subparsers: '_SubParsers') -> ArgumentParser:
10331033
'Default: False'
10341034
),
10351035
)
1036+
cube.add_argument(
1037+
'-l', '--linear',
1038+
action='store_true',
1039+
help=(
1040+
'Show the scrambled cube in linear mode.\n'
1041+
'Default: False'
1042+
),
1043+
)
1044+
cube.add_argument(
1045+
'-s', '--no-color',
1046+
action='store_true',
1047+
help=(
1048+
'Show the scrambled cube without color.\n'
1049+
'Default: False'
1050+
),
1051+
)
10361052

10371053
session = parser.add_argument_group('Session')
10381054
session.add_argument(

term_timer/manage.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ def __init__( # noqa: PLR0913
318318
iterations: int,
319319
easy_cross: bool,
320320
show_cube: bool,
321+
linear: bool,
322+
no_color: bool,
321323
output_format: str,
322324
seed: str,
323325
rng: Random,
@@ -331,6 +333,8 @@ def __init__( # noqa: PLR0913
331333
iterations: The number of random moves per scramble (0 for auto).
332334
easy_cross: Whether to generate scrambles with easy crosses.
333335
show_cube: Whether to display visual cube representations.
336+
linear: Wether to display the cube in linear.
337+
no_color: Do not use color to display the cube.
334338
output_format: Output format ('terminal' or 'markdown').
335339
seed: Seed used for the RNG.
336340
rng: Random number generator.
@@ -341,6 +345,8 @@ def __init__( # noqa: PLR0913
341345
self.iterations = iterations
342346
self.easy_cross = easy_cross
343347
self.show_cube = show_cube
348+
self.linear = linear
349+
self.no_color = no_color
344350
self.output_format = output_format
345351
self.seed = seed
346352
self.rng = rng
@@ -413,23 +419,21 @@ def run_markdown(self) -> None:
413419
f'**Generated:** { timestamp }',
414420
cube_size_str,
415421
f'**Count:** { self.scrambles }',
416-
'**Parameters:**',
417422
))
418423
params = []
419424

420425
if self.seed:
421426
params.append(f'- Seed: { self.seed }')
422-
else:
423-
params.append('- Seed: Random')
424427

425428
if self.iterations:
426429
params.append(f'- Iterations: { self.iterations }')
427-
else:
428-
params.append('- Iterations: Auto')
429430

430-
params.append(f'- Easy Cross: { "Yes" if self.easy_cross else "No" }')
431+
if self.easy_cross:
432+
params.append('- Easy Cross: Yes')
433+
434+
if params:
435+
output_lines.extend(['**Customization:**', *params])
431436

432-
output_lines.extend(params)
433437
output_lines.extend(('', '---', ''))
434438

435439
# Generate scrambles
@@ -459,19 +463,27 @@ def run_markdown(self) -> None:
459463
)
460464
output_lines.append(scrambled_str)
461465

466+
output_lines.append('')
467+
462468
# Cube visualization if requested
463469
if self.show_cube:
464-
output_lines.extend(('', '### Cube Visualization', ''))
470+
output_lines.append('### Cube Visualization')
465471

466-
cube_emoji = cube.display(orientation='UF', facelet='emoji')
472+
cube_display = cube.display(
473+
orientation='UF',
474+
facelet='no-color' if self.no_color else 'emoji',
475+
mode='linear' if self.linear else '',
476+
)
467477
output_lines.extend((
468478
'```',
469-
cube_emoji.rstrip('\n'),
479+
cube_display.rstrip('\n'),
470480
'```',
471481
'',
472482
))
473483

474-
output_lines.extend(('---', ''))
484+
output_lines.append('---')
485+
if counter < self.scrambles - 1:
486+
output_lines.append('')
475487

476488
# Print the complete markdown document
477489
print('\n'.join(output_lines)) # noqa: T201

term_timer/scripts/timer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ def manage(command: str, options: Namespace) -> int:
325325
iterations=options.iterations,
326326
easy_cross=options.easy_cross,
327327
show_cube=options.show_cube,
328+
linear=options.linear,
329+
no_color=options.no_color,
328330
output_format=options.format,
329331
seed=options.seed,
330332
rng=rng,

0 commit comments

Comments
 (0)