-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathroot.py
More file actions
27 lines (22 loc) · 796 Bytes
/
root.py
File metadata and controls
27 lines (22 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import click
import sys
import os
from commands.get import get
from commands.set import set
from commands.delete import delete
from commands.export import export
@click.group(invoke_without_command=True)
@click.pass_context
def root_command(ctx):
"""Linux User Management CLI."""
ctx.ensure_object(dict)
if os.name != 'nt' and hasattr(os, 'geteuid') and os.geteuid() != 0:
click.echo("This program requires root privileges to manage users. Please run with sudo.")
sys.exit(1)
if ctx.invoked_subcommand is None:
click.echo(ctx.get_help())
# Register all available commands
root_command.add_command(get, name="get")
root_command.add_command(set, name="set")
root_command.add_command(delete, name="delete")
root_command.add_command(export, name="export")