Skip to content

Commit

Permalink
[CLI] Sketch label management (#3262)
Browse files Browse the repository at this point in the history
* initial commit to add label handling to the cli client

* Update cli_client/python/timesketch_cli_client/commands/sketch.py

Co-authored-by: Janosch <[email protected]>

---------

Co-authored-by: Janosch <[email protected]>
  • Loading branch information
jaegeral and jkppr authored Jan 15, 2025
1 parent 8e4df47 commit 449c7fe
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cli_client/python/timesketch_cli_client/commands/sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,31 @@ def unarchive_sketch(ctx):
if sketch.is_archived():
sketch.unarchive()
click.echo("Sketch unarchived")


@sketch_group.command("add_label", help="Add a label to a sketch")
@click.option("--label", required=True, help="Name of label to add.")
@click.pass_context
def add_label(ctx, label):
"""Add a label to a sketch."""
sketch = ctx.obj.sketch
sketch.add_sketch_label(label)
click.echo("Label added")


@sketch_group.command("list_label", help="List labels of sketch")
@click.pass_context
def list_label(ctx):
"""List labels of a sketch."""
sketch = ctx.obj.sketch
click.echo(sketch.labels)


@sketch_group.command("remove_label", help="Remove a label from a sketch")
@click.option("--label", required=True, help="Name of label to remove.")
@click.pass_context
def remove_label(ctx, label):
"""Remove a label from a sketch."""
sketch = ctx.obj.sketch
sketch.remove_sketch_label(label)
click.echo("Label removed.")
32 changes: 32 additions & 0 deletions docs/guides/user/cli-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,38 @@ Running `sketch unarchive` will set the archive flag to the sketch.

Running `sketch export` will export the complete Sketch to a file.

### Labels

#### list_labels

Running `sketch list_labels` will give you a list of all labels of a sketch.

Example:
```bash
timesketch --sketch 14 --output-format json sketch list_label
['test', 'foobar']
```

#### add label

Running `sketch add_label --label foobar` will add the label `foobar` to the sketch.

Example:
```bash
timesketch --sketch 14 --output-format json sketch add_label --label=foobar
Label added
```

#### Remove label

Running `sketch remove_label --label foobar` will remove the label `foobar` from the sketch.

Example:
```bash
timesketch --sketch 14 --output-format json sketch remove_label --label=foobar
Label removed
```

## Intelligence

Intelligence is always sketch specific. The same can be achieved using
Expand Down

0 comments on commit 449c7fe

Please sign in to comment.