Skip to content

Command line

Usage: kcg [OPTIONS] COMMAND [ARGS]...

  The command line of KCG: the Keyboard Configuration Generator.

Options:
  --help  Show this message and exit.

Commands:
  generate  Generate configuration files for a given target.

Command generate

Usage: kcg generate [OPTIONS] CONTEXT COMMAND [ARGS]...

  Generate configuration files for a given target.

  CONTEXT_FILE: Path to the context file. Run 'kcg help context' to know more.

Options:
  -o, --out DIRECTORY  Directory where to write output files. By default:
                       working directory.
  --help               Show this message and exit.

Commands:
  doc         Generate documentation files.
  kbdmap      Generate the key kbdmap file.
  keymaps     Generate the key map file.
  klavaro     Generate the config files for Klavaro.
  ktouch      Generate the config files for ktouch.
  mac         Generate config files for Mac.
  map         Generate the layout map in a text file.
  svg         Generate a picture of the layout in a svg file.
  typefaster  Generate the config files for typefaster.
  win         Generate config files for Windows.
  wscons      Generate the wscons file.
  x           Generate config files for Linux X service.

Python docs

This module configures the command line of KCG.

in this file, the word 'context' is used with two different meanings:
  • one is the context object of Click, stored in variable 'ctx'. Read https://click.palletsprojects.com/en/8.1.x/api/#click.Context
  • the other is the context file of KCG (this tool), which is a INI file. Its documentation is in doc/context.md

doc(ctx)

Generate documentation files.

Source code in kcg/cli.py
55
56
57
58
59
60
61
62
@generate.command()
@click.pass_context
def doc(ctx):
    """Generate documentation files."""
    try:
        generators.doc.generate(ctx.obj["context"], ctx.obj["output_dir"])
    except GenerationError as exc:
        raise click.ClickException(exc)

generate(ctx, context, output_dir)

Generate configuration files for a given target.

CONTEXT_FILE: Path to the context file. Read documentation to know more.

Source code in kcg/cli.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@kcg_main_cli.group()
@click.pass_context
@click.argument(
    "context",
    type=ContextType(),
)
@click.option(
    "-o",
    "--out",
    "output_dir",
    type=click.Path(
        exists=True, file_okay=False, writable=True, path_type=pathlib.Path
    ),
    help="Directory where to write output files. By default: working directory.",
)
def generate(ctx, context, output_dir):
    """Generate configuration files for a given target.

    CONTEXT_FILE: Path to the context file. Read documentation to know more.
    """
    ctx.ensure_object(dict)
    ctx.obj["context"] = context
    ctx.obj["output_dir"] = output_dir

kbdmap()

Generate the key kbdmap file.

Source code in kcg/cli.py
139
140
141
142
@generate.command()
def kbdmap():
    """Generate the key kbdmap file."""
    raise NotImplementedError

kcg_main_cli()

The command line of KCG: the Keyboard Configuration Generator.

Source code in kcg/cli.py
25
26
27
@click.group()
def kcg_main_cli():
    """The command line of KCG: the Keyboard Configuration Generator."""

keymaps()

Generate the key map file.

Source code in kcg/cli.py
133
134
135
136
@generate.command()
def keymaps():
    """Generate the key map file."""
    raise NotImplementedError

klavaro()

Generate the config files for Klavaro.

Source code in kcg/cli.py
115
116
117
118
@generate.command()
def klavaro():
    """Generate the config files for Klavaro."""
    raise NotImplementedError

ktouch()

Generate the config files for ktouch.

Source code in kcg/cli.py
121
122
123
124
@generate.command()
def ktouch():
    """Generate the config files for ktouch."""
    raise NotImplementedError

mac()

Generate config files for Mac.

Source code in kcg/cli.py
 97
 98
 99
100
@generate.command()
def mac():
    """Generate config files for Mac."""
    raise NotImplementedError

svg()

Generate a picture of the layout in a svg file.

Source code in kcg/cli.py
109
110
111
112
@generate.command()
def svg():
    """Generate a picture of the layout in a svg file."""
    raise NotImplementedError

typefaster()

Generate the config files for typefaster.

Source code in kcg/cli.py
127
128
129
130
@generate.command()
def typefaster():
    """Generate the config files for typefaster."""
    raise NotImplementedError

win(ctx, target)

Generate config files for Windows.

Source code in kcg/cli.py
81
82
83
84
85
86
87
88
89
90
91
92
93
94
@generate.command()
@click.pass_context
@click.option(
    "-t",
    "--target",
    type=click.Choice(["azerty", "bépo", "qwertz"]),
    help="A single target (file) to generate. By default, every files are generated.",
)
def win(ctx, target):
    """Generate config files for Windows."""
    try:
        generators.win.generate(ctx.obj["context"], ctx.obj["output_dir"], target)
    except GenerationError as exc:
        raise click.ClickException(exc)

wscons()

Generate the wscons file.

Source code in kcg/cli.py
145
146
147
148
@generate.command()
def wscons():
    """Generate the wscons file."""
    raise NotImplementedError

x(ctx, target)

Generate config files for Linux X service.

Source code in kcg/cli.py
65
66
67
68
69
70
71
72
73
74
75
76
77
78
@generate.command()
@click.pass_context
@click.option(
    "-t",
    "--target",
    type=click.Choice(["xkb-root", "xkb-user", "xmodmap", "xcompose"]),
    help="A single target (file) to generate. By default, every files are generated.",
)
def x(ctx, target):  # pylint: disable=C0103
    """Generate config files for Linux X service."""
    try:
        generators.x.generate(ctx.obj["context"], ctx.obj["output_dir"], target)
    except GenerationError as exc:
        raise click.ClickException(exc)