A examples/simple.py => examples/simple.py +14 -0
@@ 0,0 1,14 @@
+from climatik import command, run
+
+@command
+def sum(a:int, b:int):
+ """Sum two integers"""
+ print(a + b)
+
+@command
+def mult(a:int, b:int):
+ """Multiply two integers"""
+ print(a * b)
+
+if __name__ == "__main__":
+ run()
A examples/vm.py => examples/vm.py +69 -0
@@ 0,0 1,69 @@
+from typing import Optional
+from climatik import command, group, run
+
+@command
+def ps(all:bool):
+ """List running VMs.
+
+ @param all: list also stopped VMs
+ """
+
+ p = ['alpine-001', 'fedora']
+ if all:
+ p += ['debian11']
+ print('\n'.join(p))
+
+@command
+def stop(name:str):
+ """Stop a VM.
+
+ @param name: VM to stop
+ """
+ print(f"Stopping {name}...")
+
+@command
+def info(name:Optional[str] = None):
+ """Print info about VMs.
+
+ If no name is passed, a summary is printed
+ """
+
+ if name is None:
+ print('alpine-001 - running')
+ print('\tRam: 500MB cpu: 10%')
+ print()
+ print('fedora - running')
+ print('\tRam: 1.5GB cpu: 40%')
+ else:
+ print(f'{name}')
+ print('\tRam: 1.5GB')
+ print('\tcpu: 40%')
+ print('\tdisk: 1GB')
+
+
+with group('image', help='Image management', description='Manage system images'):
+ @command
+ def ls():
+ """List images"""
+ print("no images")
+
+ @command
+ def rm(name:str):
+ """Remove image from system.
+
+ @param name: image name to remove.
+ """
+ print(f"image '{name} does not exists")
+
+ @command
+ def purge(force:bool):
+ """Remove unused images from system.
+
+ Images used by running processes are kept, unless --force is passed.
+
+ @param force: remove in use images (dangerous!)
+ """
+ print("0 images removed")
+
+if __name__ == "__main__":
+ run(description="Manage VMs (not really)")