Skip to content

Commit

Permalink
Prepare for v0.8.0
Browse files Browse the repository at this point in the history
See changelog for more details.
  • Loading branch information
biozz committed Sep 30, 2022
1 parent a051da9 commit 83e1e53
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 145 deletions.
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## v0.8.0 - 2022-09-30

The release started as a minor one to add support for includes (#4). But ended up as quite a big one, because recent releases of Taskfile added features, which allowed removal of `pyyaml` dependency and bumping internal python version to `3.8`.

Here goes a proper list of changes:

- add support for includes by utilizing `--list-all` flag (#4)
- remove `pyyaml` dependency
- bump internal python version to `3.8`
- bump dev dependencies
- update README regarding python version, features and installation

## v0.7.0 - 2021-07-16

Refactor and improve multiple folders handling.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Ivan Elfimov <[email protected]>
Copyright (c) 2022 Ivan Elfimov <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@

![Package Control](https://img.shields.io/packagecontrol/dt/Taskfile)

A Sublime Text 4 plugin for running tasks from [Taskfile](https://taskfile.dev). It adds `Taskfile: Run Task` to your command palette and you can select which task to run. The output of the task is than displayed in the quick panel on the bottom.
A Sublime Text 4 plugin for running tasks from [Taskfile](https://taskfile.dev). It adds `Taskfile: Run Task` to your command palette and you can select which task to run. The output of the task is then displayed in the quick panel on the bottom.

It is also possible to initialize the `Taskfile` with `Taskfile: Init` command, which basically does `task -i` in one of the project directories you chose.
It is also possible to initialize the `Taskfile` with `Taskfile: Init` command, which basically does `task -i` in one of the project directories you choose.

![Usage](Usage.gif)

- made for Sublime Text 4
- uses [Sublime's python version 3.3](https://www.sublimetext.com/docs/api_environments.html#selecting_python_version), but waiting to migrate to 3.8 once dependencies issue is resolved, see [v0.5.0](https://github.com/biozz/sublime-taskfile/releases/tag/v0.5.0) release notes for more details
- uses [`pyyaml`](https://github.com/packagecontrol/pyyaml) dependency
- has no external dependencies (other than `task` command)
- properly handles multiple open directories
- supports taskfile includes
- does not and will not ship any custom syntax definitions (see installation notes for more details)

## Installation

Use `Package Control: Install Package` command and search for `Taskfile`.
First, [install Taskfile command](https://taskfile.dev/installation/).

Then use `Package Control: Install Package` command and search for `Taskfile`.

If you want to have a hints on which keys are available and what they do, there is an [official JSON schema for Taskfile](https://json.schemastore.org/taskfile.json), which can be loaded automatically once you install [LSP](packagecontrol.io/packages/LSP) and [LSP-yaml](https://packagecontrol.io/packages/LSP-yaml) packages.

Expand Down
32 changes: 22 additions & 10 deletions Taskfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
import subprocess
import time
from functools import partial

import sublime
import sublime_plugin
import yaml

TASKFILE_NAME = "Taskfile.yml"

Expand Down Expand Up @@ -61,9 +61,7 @@ def select_task(self, folders, index):
if index < 0:
return
folder = folders[index]
taskfile_path = os.path.join(folder, TASKFILE_NAME)
res = yaml.load(open(taskfile_path), Loader=yaml.FullLoader)
items = self.get_tasks_quick_panel_items(res)
items = self.get_tasks_quick_panel_items(folder)
on_done = partial(self.run_task, items, str(folder))
self.window.show_quick_panel(items, on_done)

Expand All @@ -79,13 +77,27 @@ def run_task(self, quick_panel_items, working_dir, index):
},
)

def get_tasks_quick_panel_items(self, taskfile):
def get_tasks_quick_panel_items(self, folder):
result = []
for task_name, task in taskfile.get("tasks").items():
summary = task.get("summary")
if summary:
summary = summary.split("\n")[0]
item = sublime.QuickPanelItem(task_name, summary)
# -s flag (silent output) will not work here, because I need task descriptions
# the downside is that I have to parse human-readable output of the command
list_all_result = subprocess.run(
["task", "--list-all"], capture_output=True, cwd=folder
)
if list_all_result.returncode != 0:
print(list_all_result.stderr.decode())
self.window.status_message(
"Unable list tasks: see Sublime's console for more info"
)
return []
# Stdout is sliced because the first line is a general Taskfile message
tasks = list_all_result.stdout.decode().split("* ")[1:]
for task in tasks:
name_raw, summary_raw = task.split("\t")
# The name of each task ends with colon and a space, they need to be removed
name = name_raw[:-2]
summary = summary_raw.strip().replace("\n\n", "\n").split("\n")
item = sublime.QuickPanelItem(name, summary)
result.append(item)
return result

Expand Down
6 changes: 3 additions & 3 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ version: '3'

tasks:
lint:
summary: |
Lint source code with black and isort.
desc: |
Lint source code with various utilities.
cmds:
- black .
- isort .
- autoflake .
clean:
summary: Remove temporary and cache files.
desc: Remove temporary and cache files.
cmds:
- find . -name '*.pyc' | xargs rm -rf
- find . -name '*__pycache__' | xargs rm -rf
Expand Down
7 changes: 0 additions & 7 deletions dependencies.json

This file was deleted.

3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"0.2.0": "messages/0.2.0.md",
"0.3.0": "messages/0.3.0.md",
"0.4.0": "messages/0.4.0.md",
"0.5.0": "messages/0.5.0.md"
"0.5.0": "messages/0.5.0.md",
"0.8.0": "messages/0.8.0.md"
}
11 changes: 11 additions & 0 deletions messages/0.8.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## v0.8.0 - 2022-09-30

The release started as a minor one to add support for includes (#4). But ended up as quite a big one, because recent releases of Taskfile added features, which allowed removal of `pyyaml` dependency and bumping internal python version to `3.8`.

Here goes a proper list of changes:

- add support for includes by utilizing `--list-all` flag (#4)
- remove `pyyaml` dependency
- bump internal python version to `3.8`
- bump dev dependencies
- update README regarding python version, features and installation
Loading

0 comments on commit 83e1e53

Please sign in to comment.