├── .clikan.yaml ├── .deepsource.toml ├── .github └── workflows │ ├── pythonpackage.yml │ └── pythonpackagedeploy.yml ├── .gitignore ├── .index ├── License.txt ├── MANIFEST.in ├── README.md ├── SECURITY.md ├── VERSION ├── aliases.ini ├── clikan.py ├── clikan_test.py ├── docs ├── icon-256x256.png └── icon.graffle ├── requirements.txt ├── screenshot.png ├── setup.py └── tests ├── no_repaint ├── .clikan.yaml └── donotdelete ├── no_taskname ├── .clikan.yaml └── donotdelete ├── repaint ├── .clikan.yaml └── donotdelete └── taskname ├── .clikan.yaml └── donotdelete /.clikan.yaml: -------------------------------------------------------------------------------- 1 | clikan_data: ./.clikan.dat 2 | -------------------------------------------------------------------------------- /.deepsource.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | test_patterns = ["clikan_test.py"] 4 | 5 | [[analyzers]] 6 | name = "python" 7 | enabled = true 8 | 9 | [analyzers.meta] 10 | runtime_version = "3.x.x" 11 | -------------------------------------------------------------------------------- /.github/workflows/pythonpackage.yml: -------------------------------------------------------------------------------- 1 | # This workflow will install Python dependencies, run tests and lint with a variety of Python versions 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions 3 | 4 | name: Python package 5 | 6 | on: 7 | push: 8 | branches: 9 | - '*' 10 | - '!master' 11 | pull_request: 12 | branches: [ develop ] 13 | 14 | jobs: 15 | build: 16 | strategy: 17 | matrix: 18 | platform: [ubuntu-latest, macos-latest, windows-latest] 19 | python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] 20 | runs-on: ${{ matrix.platform }} 21 | steps: 22 | - uses: actions/checkout@v2 23 | - name: Set up Python ${{ matrix.python-version }} 24 | uses: actions/setup-python@v2 25 | with: 26 | python-version: ${{ matrix.python-version }} 27 | architecture: x64 28 | - name: Setup setup.py 29 | run: | 30 | pip install -r requirements.txt 31 | python setup.py install 32 | - name: Lint with flake8 and pycodestyle 33 | run: | 34 | pip install flake8 pycodestyle 35 | # stop the build if there are Python syntax errors or undefined names 36 | # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide 37 | flake8 . --count --select=E9,F63,F7,F82 --exit-zero --max-complexity=10 --max-line-length=127 --statistics 38 | pycodestyle clikan.py 39 | - name: Test with pytest 40 | run: | 41 | pip install pytest 42 | pytest clikan_test.py 43 | 44 | 45 | -------------------------------------------------------------------------------- /.github/workflows/pythonpackagedeploy.yml: -------------------------------------------------------------------------------- 1 | # This workflow will install Python dependencies, run tests and lint with a variety of Python versions 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions 3 | 4 | name: Python package deploy 5 | 6 | on: 7 | push: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | strategy: 15 | matrix: 16 | python-version: [3.11] 17 | environment: test 18 | permissions: write-all 19 | # IMPORTANT: this permission is mandatory for trusted publishing 20 | steps: 21 | - uses: actions/checkout@v2 22 | - name: Set up Python ${{ matrix.python-version }} 23 | uses: actions/setup-python@v2 24 | with: 25 | python-version: ${{ matrix.python-version }} 26 | architecture: x64 27 | - name: Set variables 28 | run: | 29 | VER=$(cat VERSION) 30 | echo "VERSION=$VER" >> $GITHUB_ENV 31 | HASH=$(git rev-parse --short "$GITHUB_SHA") 32 | echo "COMMIT_HASH=$HASH" >> $GITHUB_ENV 33 | - name: Setup setup.py 34 | run: | 35 | pip install -r requirements.txt 36 | python setup.py install 37 | - name: Lint with flake8 38 | run: | 39 | pip install flake8 40 | # stop the build if there are Python syntax errors or undefined names 41 | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics 42 | # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide 43 | flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics 44 | - name: Test with pytest 45 | run: | 46 | pip install pytest 47 | pytest clikan_test.py 48 | - name: Create dist 49 | run: | 50 | pip install build 51 | python -m build 52 | - name: Create tag 53 | uses: actions/github-script@v5 54 | with: 55 | github-token: ${{ github.token }} 56 | script: | 57 | github.rest.git.createRef({ 58 | owner: context.repo.owner, 59 | repo: context.repo.repo, 60 | ref: "refs/tags/${{ env.VERSION }}.${{ env.COMMIT_HASH }}", 61 | sha: context.sha 62 | }) 63 | - name: Publish a Python distribution to PyPI 64 | uses: pypa/gh-action-pypi-publish@v1.8.14 65 | with: 66 | repository-url: https://test.pypi.org/legacy/ 67 | - name: Post to Mastodon 68 | uses: rzr/fediverse-action@master 69 | with: 70 | access-token: ${{ secrets.MASTODON_ACCESS_TOKEN }} 71 | message: "#clikan - new release: https://github.com/${{ github.repository }}/releases/tag/${{ env.VERSION }}.${{ env.COMMIT_HASH }} - get your personal CLI #kanban board!" 72 | 73 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .clikan.dat 2 | build/ 3 | clikan.egg-info/ 4 | clikan.pyc 5 | setup.pyc 6 | dist/ 7 | venv/ 8 | venv3/ 9 | .cache/ 10 | .pytest_cache/ 11 | __pycache__/ 12 | .vscode 13 | -------------------------------------------------------------------------------- /.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitplummer/clikan/c296deb1f053a5ba28bb5d1fe13741c8e52df564/.index -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright 2017 Kit Plummer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include VERSION 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # clikan: CLI (Personal) Kanban 2 | There has been a little chatter about 'personal' kanban on the tubes lately. I don't know about the need to hype it as personal, but if you're looking to get your head wrapped around stuff needing to get done - then kanban is a healthy tool. clikan is a super simple command-line utility for tracking tasks following the Japanese Kanban (boarding) style. clikan's core intent is to be easy to use, and to maintain simplicity. 3 | 4 | ![icon](docs/icon-256x256.png) 5 | 6 | ## Installation 7 | 8 | $ `pip install clikan` 9 | 10 | ### Alternative Installation with Guix 11 | 12 | $ `guix install clikan` 13 | 14 | ### Create a `.clikan.yaml` in your $HOME directory 15 | 16 | ```yaml 17 | --- 18 | clikan_data: /Users/kplummer/.clikan.dat 19 | limits: 20 | todo: 10 21 | wip: 3 22 | done: 10 23 | taskname: 40 24 | repaint: true 25 | ``` 26 | 27 | * `clikan_data` is the datastore file location. 28 | * `limits:todo` is the max number of items allowed in the todo column, keep this small - you want a smart list, not an ice box of ideas here. 29 | * `limits:wip` is the max number of items allowed in in-progress at a given time. Context-switching is a farce, focus on one or two tasks at a time. 30 | * `limits:done` is the max number of done items visible, they'll still be stored. It's good to see a list of done items, for pure psyche. 31 | * `limits:taskname` is the max length of a task text. 32 | * `repaint` is used to tell `clikan` to show the display after every successful command - default is false/off. 33 | 34 | -- or -- 35 | 36 | $ `clikan configure` 37 | 38 | to create a default data file location. 39 | 40 | This is where the tool will store the history of files. It's configurable so you can put the data in a Dropbox or other cloud-watched directory for safe archiving/backing up. 41 | 42 | If you're like me, even `clikan` is a bunch too many characters to type, so shorten with an alias in my shell config to `clik`. 43 | 44 | ## Usage 45 | The basic usage of clikan breaks down into three basic commands: 46 | 47 | ### Show 48 | 49 | $ `clikan show` (alias: s) 50 | 51 | ### Add 52 | 53 | $ `clikan add [task text]` (alias: a) 54 | 55 | ### Promote 56 | 57 | $ `clikan promote [task id]` (alias: p) 58 | 59 | And there are more supporting commands: 60 | 61 | ### Regress 62 | 63 | $ `clikan regress [task id]` 64 | 65 | ### Delete 66 | 67 | $ `clikan delete [task id]` (alias: d) 68 | 69 | ### Configure 70 | 71 | $ `clikan configure` 72 | 73 | ### Screenshot 74 | 75 | ![Screenshot](screenshot.png) 76 | 77 | ## Development 78 | 79 | It's Python code. Fork, fix, and submit a PR - it'd be super appreciated. 80 | 81 | Tests? Um, yeah. 82 | 83 | ### Testing 84 | 85 | Updated test suite to include 3.6-3.9 on Windows, macOS and Ubuntu. 86 | 87 | ***Definitely*** need some help here. There is a basic test suite available in `clikan_test.py`. 88 | 89 | To run it, make sure ~/.clikan.dat is empty, or specify a test locale 90 | with the `CLIKAN_HOME` environment variable the you can run: 91 | 92 | ``` 93 | CLIKAN_HOME=/tmp pytest clikan_test.py 94 | ``` 95 | 96 | The project uses this environment variable feature to test different functional configuration scenarios internally to the test suite. 97 | 98 | Am considering adding the `--config_file` feature to allow for specifying the path to the config file as well. If this is something you're interesting in or believe would be beneficial let me know through an Github issue. 99 | ## License 100 | 101 | ``` 102 | MIT License 103 | 104 | Copyright 2018 Kit Plummer 105 | 106 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 107 | 108 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 109 | 110 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 111 | ``` 112 | 113 | ## Support 114 | 115 | Github Issues 116 | https://github.com/kitplummer/clikan/issues 117 | 118 | Feel free to use issues as a forum-like thing too, ask questions or post comments. 119 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | None. Use at your own risk. This is a basic TODO app, and nothing is tracked or stored beyond the configured data file - which is text-based. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | If however there is something blaringly dumb, or risky even, please create an issue. 10 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.4.4 2 | -------------------------------------------------------------------------------- /aliases.ini: -------------------------------------------------------------------------------- 1 | [aliases] 2 | a=add 3 | s=show 4 | d=delete 5 | p=promote 6 | -------------------------------------------------------------------------------- /clikan.py: -------------------------------------------------------------------------------- 1 | from rich import print 2 | from rich.console import Console 3 | from rich.table import Table 4 | import click 5 | from click_default_group import DefaultGroup 6 | import yaml 7 | import os 8 | import sys 9 | from textwrap import wrap 10 | import collections 11 | import datetime 12 | import configparser 13 | import importlib 14 | 15 | VERSION = importlib.metadata.version('clikan') 16 | 17 | 18 | class Config(object): 19 | """The config in this example only holds aliases.""" 20 | 21 | def __init__(self): 22 | self.path = os.getcwd() 23 | self.aliases = {} 24 | 25 | def read_config(self, filename): 26 | parser = configparser.RawConfigParser() 27 | parser.read([filename]) 28 | try: 29 | self.aliases.update(parser.items('aliases')) 30 | except configparser.NoSectionError: 31 | pass 32 | 33 | 34 | pass_config = click.make_pass_decorator(Config, ensure=True) 35 | 36 | 37 | class AliasedGroup(DefaultGroup): 38 | """This subclass of a group supports looking up aliases in a config 39 | file and with a bit of magic. 40 | """ 41 | 42 | def get_command(self, ctx, cmd_name): 43 | # Step one: bulitin commands as normal 44 | rv = click.Group.get_command(self, ctx, cmd_name) 45 | if rv is not None: 46 | return rv 47 | 48 | # Step two: find the config object and ensure it's there. This 49 | # will create the config object is missing. 50 | cfg = ctx.ensure_object(Config) 51 | 52 | # Step three: lookup an explicit command aliase in the config 53 | if cmd_name in cfg.aliases: 54 | actual_cmd = cfg.aliases[cmd_name] 55 | return click.Group.get_command(self, ctx, actual_cmd) 56 | 57 | # Alternative option: if we did not find an explicit alias we 58 | # allow automatic abbreviation of the command. "status" for 59 | # instance will match "st". We only allow that however if 60 | # there is only one command. 61 | matches = [x for x in self.list_commands(ctx) 62 | if x.lower().startswith(cmd_name.lower())] 63 | if not matches: 64 | return None 65 | elif len(matches) == 1: 66 | return click.Group.get_command(self, ctx, matches[0]) 67 | ctx.fail('Too many matches: %s' % ', '.join(sorted(matches))) 68 | 69 | 70 | def read_config(ctx, param, value): 71 | """Callback that is used whenever --config is passed. We use this to 72 | always load the correct config. This means that the config is loaded 73 | even if the group itself never executes so our aliases stay always 74 | available. 75 | """ 76 | cfg = ctx.ensure_object(Config) 77 | if value is None: 78 | value = os.path.join(os.path.dirname(__file__), 'aliases.ini') 79 | cfg.read_config(value) 80 | return value 81 | 82 | 83 | @click.version_option(VERSION) 84 | @click.command(cls=AliasedGroup, default='show', default_if_no_args=True) 85 | def clikan(): 86 | """clikan: CLI personal kanban """ 87 | 88 | 89 | @clikan.command() 90 | def configure(): 91 | """Place default config file in CLIKAN_HOME or HOME""" 92 | home = get_clikan_home() 93 | data_path = os.path.join(home, ".clikan.dat") 94 | config_path = os.path.join(home, ".clikan.yaml") 95 | if (os.path.exists(config_path) and not 96 | click.confirm('Config file exists. Do you want to overwrite?')): 97 | return 98 | with open(config_path, 'w') as outfile: 99 | conf = {'clikan_data': data_path} 100 | yaml.dump(conf, outfile, default_flow_style=False) 101 | click.echo("Creating %s" % config_path) 102 | 103 | 104 | @clikan.command() 105 | @click.argument('tasks', nargs=-1) 106 | def add(tasks): 107 | """Add a tasks in todo""" 108 | config = read_config_yaml() 109 | dd = read_data(config) 110 | 111 | if ('limits' in config and 'taskname' in config['limits']): 112 | taskname_length = config['limits']['taskname'] 113 | else: 114 | taskname_length = 40 115 | 116 | for task in tasks: 117 | if len(task) > taskname_length: 118 | click.echo('Task must be at most %s chars, Brevity counts: %s' 119 | % (taskname_length, task)) 120 | else: 121 | todos, inprogs, dones = split_items(config, dd) 122 | if ('limits' in config and 'todo' in config['limits'] and 123 | int(config['limits']['todo']) <= len(todos)): 124 | click.echo('No new todos, limit reached already.') 125 | else: 126 | od = collections.OrderedDict(sorted(dd['data'].items())) 127 | new_id = 1 128 | if bool(od): 129 | new_id = next(reversed(od)) + 1 130 | entry = ['todo', task, timestamp(), timestamp()] 131 | dd['data'].update({new_id: entry}) 132 | click.echo("Creating new task w/ id: %d -> %s" 133 | % (new_id, task)) 134 | 135 | write_data(config, dd) 136 | if ('repaint' in config and config['repaint']): 137 | display() 138 | 139 | 140 | @clikan.command() 141 | @click.argument('ids', nargs=-1) 142 | def delete(ids): 143 | """Delete task""" 144 | config = read_config_yaml() 145 | dd = read_data(config) 146 | 147 | for id in ids: 148 | try: 149 | item = dd['data'].get(int(id)) 150 | if item is None: 151 | click.echo('No existing task with that id: %d' % int(id)) 152 | else: 153 | item[0] = 'deleted' 154 | item[2] = timestamp() 155 | dd['deleted'].update({int(id): item}) 156 | dd['data'].pop(int(id)) 157 | click.echo('Removed task %d.' % int(id)) 158 | except ValueError: 159 | click.echo('Invalid task id') 160 | 161 | write_data(config, dd) 162 | if ('repaint' in config and config['repaint']): 163 | display() 164 | 165 | 166 | @clikan.command() 167 | @click.argument('ids', nargs=-1) 168 | def promote(ids): 169 | """Promote task""" 170 | config = read_config_yaml() 171 | dd = read_data(config) 172 | todos, inprogs, dones = split_items(config, dd) 173 | 174 | for id in ids: 175 | try: 176 | item = dd['data'].get(int(id)) 177 | if item is None: 178 | click.echo('No existing task with that id: %s' % id) 179 | elif item[0] == 'todo': 180 | if ('limits' in config and 'wip' in config['limits'] and 181 | int(config['limits']['wip']) <= len(inprogs)): 182 | click.echo( 183 | 'Can not promote, in-progress limit of %s reached.' 184 | % config['limits']['wip'] 185 | ) 186 | else: 187 | click.echo('Promoting task %s to in-progress.' % id) 188 | dd['data'][int(id)] = [ 189 | 'inprogress', 190 | item[1], timestamp(), 191 | item[3] 192 | ] 193 | elif item[0] == 'inprogress': 194 | click.echo('Promoting task %s to done.' % id) 195 | dd['data'][int(id)] = ['done', item[1], timestamp(), item[3]] 196 | else: 197 | click.echo('Can not promote %s, already done.' % id) 198 | except ValueError: 199 | click.echo('Invalid task id') 200 | 201 | write_data(config, dd) 202 | if ('repaint' in config and config['repaint']): 203 | display() 204 | 205 | 206 | @clikan.command() 207 | @click.argument('id', nargs=-1) 208 | def regress(ids): 209 | """Regress task""" 210 | config = read_config_yaml() 211 | dd = read_data(config) 212 | 213 | for id in ids: 214 | item = dd['data'].get(int(id)) 215 | if item is None: 216 | click.echo('No existing task with id: %s' % id) 217 | elif item[0] == 'done': 218 | click.echo('Regressing task %s to in-progress.' % id) 219 | dd['data'][int(id)] = ['inprogress', item[1], timestamp(), item[3]] 220 | elif item[0] == 'inprogress': 221 | click.echo('Regressing task %s to todo.' % id) 222 | dd['data'][int(id)] = ['todo', item[1], timestamp(), item[3]] 223 | else: 224 | click.echo('Already in todo, can not regress %s' % id) 225 | 226 | write_data(config, dd) 227 | if ('repaint' in config and config['repaint']): 228 | display() 229 | 230 | 231 | # Use a non-Click function to allow for repaint to work. 232 | 233 | 234 | def display(): 235 | console = Console() 236 | """Show tasks in clikan""" 237 | config = read_config_yaml() 238 | dd = read_data(config) 239 | todos, inprogs, dones = split_items(config, dd) 240 | if 'limits' in config and 'done' in config['limits']: 241 | dones = dones[0:int(config['limits']['done'])] 242 | else: 243 | dones = dones[0:10] 244 | 245 | todos = '\n'.join([str(x) for x in todos]) 246 | inprogs = '\n'.join([str(x) for x in inprogs]) 247 | dones = '\n'.join([str(x) for x in dones]) 248 | 249 | table = Table(show_header=True, show_footer=True) 250 | table.add_column( 251 | "[bold yellow]todo[/bold yellow]", 252 | no_wrap=True, 253 | footer="clikan" 254 | ) 255 | table.add_column('[bold green]in-progress[/bold green]', no_wrap=True) 256 | table.add_column( 257 | '[bold magenta]done[/bold magenta]', 258 | no_wrap=True, 259 | footer="v.{}".format(VERSION) 260 | ) 261 | 262 | table.add_row(todos, inprogs, dones) 263 | console.print(table) 264 | 265 | 266 | @clikan.command() 267 | def show(): 268 | display() 269 | 270 | 271 | def read_data(config): 272 | """Read the existing data from the config datasource""" 273 | try: 274 | with open(config["clikan_data"], 'r') as stream: 275 | try: 276 | return yaml.safe_load(stream) 277 | except yaml.YAMLError as exc: 278 | print("Ensure %s exists, as you specified it " 279 | "as the clikan data file." % config['clikan_data']) 280 | print(exc) 281 | except IOError: 282 | click.echo("No data, initializing data file.") 283 | write_data(config, {"data": {}, "deleted": {}}) 284 | with open(config["clikan_data"], 'r') as stream: 285 | return yaml.safe_load(stream) 286 | 287 | 288 | def write_data(config, data): 289 | """Write the data to the config datasource""" 290 | with open(config["clikan_data"], 'w') as outfile: 291 | yaml.dump(data, outfile, default_flow_style=False) 292 | 293 | 294 | def get_clikan_home(): 295 | home = os.environ.get('CLIKAN_HOME') 296 | if not home: 297 | home = os.path.expanduser('~') 298 | return home 299 | 300 | 301 | def read_config_yaml(): 302 | """Read the app config from ~/.clikan.yaml""" 303 | try: 304 | home = get_clikan_home() 305 | with open(home + "/.clikan.yaml", 'r') as stream: 306 | try: 307 | return yaml.safe_load(stream) 308 | except yaml.YAMLError: 309 | print("Ensure %s/.clikan.yaml is valid, expected YAML." % home) 310 | sys.exit() 311 | except IOError: 312 | print("Ensure %s/.clikan.yaml exists and is valid." % home) 313 | sys.exit() 314 | 315 | 316 | def split_items(config, dd): 317 | todos = [] 318 | inprogs = [] 319 | dones = [] 320 | 321 | for key, value in dd['data'].items(): 322 | if value[0] == 'todo': 323 | todos.append("[%d] %s" % (key, value[1])) 324 | elif value[0] == 'inprogress': 325 | inprogs.append("[%d] %s" % (key, value[1])) 326 | else: 327 | dones.insert(0, "[%d] %s" % (key, value[1])) 328 | 329 | return todos, inprogs, dones 330 | 331 | 332 | def timestamp(): 333 | return '{:%Y-%b-%d %H:%M:%S}'.format(datetime.datetime.now()) 334 | -------------------------------------------------------------------------------- /clikan_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import click 4 | from click.testing import CliRunner 5 | from clikan import configure, clikan, add, promote, show, regress, delete 6 | import os 7 | import pathlib 8 | import tempfile 9 | 10 | # Configure Tests 11 | 12 | 13 | def test_command_help(): 14 | runner = CliRunner() 15 | result = runner.invoke(clikan, ["--help"]) 16 | assert result.exit_code == 0 17 | assert 'Usage: clikan [OPTIONS] COMMAND [ARGS]...' in result.output 18 | assert 'clikan: CLI personal kanban' in result.output 19 | 20 | 21 | def test_command_version(): 22 | version_file = open(os.path.join('./', 'VERSION')) 23 | version = version_file.read().strip() 24 | 25 | runner = CliRunner() 26 | result = runner.invoke(clikan, ["--version"]) 27 | assert result.exit_code == 0 28 | assert 'clikan, version {}'.format(version) in result.output 29 | 30 | 31 | def test_command_configure(tmp_path): 32 | runner = CliRunner() 33 | with tempfile.TemporaryDirectory() as tmpdirname: 34 | with runner.isolation( 35 | input=None, 36 | env={"CLIKAN_HOME": tmpdirname}, 37 | color=False 38 | ): 39 | result = runner.invoke(clikan, ["configure"]) 40 | assert result.exit_code == 0 41 | assert 'Creating' in result.output 42 | 43 | 44 | def test_command_configure_existing(): 45 | runner = CliRunner() 46 | with runner.isolated_filesystem(): 47 | runner.invoke(clikan, ["configure"]) 48 | result = runner.invoke(clikan, ["configure"]) 49 | 50 | assert 'Config file exists' in result.output 51 | 52 | 53 | ## Single Argument Tests 54 | 55 | # Add Tests 56 | def test_command_a(): 57 | runner = CliRunner() 58 | result = runner.invoke(clikan, ["a", "n_--task_test"]) 59 | assert result.exit_code == 0 60 | assert 'n_--task_test' in result.output 61 | 62 | 63 | # Show Tests 64 | 65 | 66 | def test_no_command(): 67 | runner = CliRunner() 68 | result = runner.invoke(clikan, []) 69 | assert result.exit_code == 0 70 | assert 'n_--task_test' in result.output 71 | 72 | 73 | def test_command_s(): 74 | runner = CliRunner() 75 | result = runner.invoke(clikan, ["s"]) 76 | assert result.exit_code == 0 77 | assert 'n_--task_test' in result.output 78 | 79 | 80 | def test_command_show(): 81 | runner = CliRunner() 82 | result = runner.invoke(show) 83 | assert result.exit_code == 0 84 | assert 'n_--task_test' in result.output 85 | 86 | 87 | def test_command_not_show(): 88 | runner = CliRunner() 89 | result = runner.invoke(show) 90 | assert result.exit_code == 0 91 | assert 'blahdyblah' not in result.output 92 | 93 | 94 | # Promote Tests 95 | 96 | 97 | def test_command_promote(): 98 | runner = CliRunner() 99 | result = runner.invoke(clikan, ['promote', '1']) 100 | assert result.exit_code == 0 101 | assert 'Promoting task 1 to in-progress.' in result.output 102 | result = runner.invoke(clikan, ['promote', '1']) 103 | assert result.exit_code == 0 104 | assert 'Promoting task 1 to done.' in result.output 105 | 106 | 107 | # Delete Tests 108 | 109 | 110 | def test_command_delete(): 111 | runner = CliRunner() 112 | result = runner.invoke(clikan, ['delete', '1']) 113 | assert result.exit_code == 0 114 | assert 'Removed task 1.' in result.output 115 | result = runner.invoke(clikan, ['delete', '1']) 116 | assert result.exit_code == 0 117 | assert 'No existing task with' in result.output 118 | 119 | 120 | ## Multiple Argument Tests 121 | 122 | # Add Tests 123 | def test_command_a_multi(): 124 | runner = CliRunner() 125 | result = runner.invoke(clikan, ["a", "n_--task_test_multi_1", "n_--task_test_multi_2", "n_--task_test_multi_3"]) 126 | assert result.exit_code == 0 127 | assert 'n_--task_test' in result.output 128 | 129 | 130 | # Show Test 131 | def test_command_show_multi(): 132 | runner = CliRunner() 133 | result = runner.invoke(show) 134 | assert result.exit_code == 0 135 | assert 'n_--task_test_multi_1' in result.output 136 | assert 'n_--task_test_multi_2' in result.output 137 | assert 'n_--task_test_multi_3' in result.output 138 | 139 | 140 | # Promote Tests 141 | def test_command_promote_multi(): 142 | runner = CliRunner() 143 | result = runner.invoke(clikan, ['promote', '1', '2']) 144 | assert result.exit_code == 0 145 | assert 'Promoting task 1 to in-progress.' in result.output 146 | assert 'Promoting task 2 to in-progress.' in result.output 147 | result = runner.invoke(clikan, ['promote', '2', '3']) 148 | assert result.exit_code == 0 149 | assert 'Promoting task 2 to done.' in result.output 150 | assert 'Promoting task 3 to in-progress.' in result.output 151 | 152 | 153 | # Delete Tests 154 | def test_command_delete_multi(): 155 | runner = CliRunner() 156 | result = runner.invoke(clikan, ['delete', '1', '2']) 157 | assert result.exit_code == 0 158 | assert 'Removed task 1.' in result.output 159 | assert 'Removed task 2.' in result.output 160 | result = runner.invoke(clikan, ['delete', '1', '2']) 161 | assert result.exit_code == 0 162 | assert 'No existing task with that id: 1' in result.output 163 | assert 'No existing task with that id: 2' in result.output 164 | 165 | 166 | # Show after delete Test 167 | def test_command_show_multi_after_delete(): 168 | runner = CliRunner() 169 | result = runner.invoke(show) 170 | assert result.exit_code == 0 171 | assert 'n_--task_test_multi_1' not in result.output 172 | assert 'n_--task_test_multi_2' not in result.output 173 | assert 'n_--task_test_multi_3' in result.output 174 | 175 | 176 | # Repaint Tests 177 | def test_repaint_config_option(): 178 | runner = CliRunner() 179 | version_file = open(os.path.join('./', 'VERSION')) 180 | version = version_file.read().strip() 181 | path_to_config = str(pathlib.Path("./tests/repaint").resolve()) 182 | with runner.isolation( 183 | input=None, 184 | env={"CLIKAN_HOME": path_to_config}, 185 | color=False 186 | ): 187 | result = runner.invoke(clikan, []) 188 | assert result.exit_code == 0 189 | assert 'clikan' in result.output 190 | result = runner.invoke(clikan, ["a", "n_--task_test"]) 191 | assert result.exit_code == 0 192 | assert 'n_--task_test' in result.output 193 | assert version in result.output 194 | 195 | 196 | def test_no_repaint_config_option(): 197 | runner = CliRunner() 198 | version_file = open(os.path.join('./', 'VERSION')) 199 | version = version_file.read().strip() 200 | path_to_config = str(pathlib.Path("./tests/no_repaint").resolve()) 201 | with runner.isolation( 202 | input=None, 203 | env={"CLIKAN_HOME": path_to_config}, 204 | color=False 205 | ): 206 | result = runner.invoke(clikan, []) 207 | assert result.exit_code == 0 208 | assert 'clikan' in result.output 209 | result = runner.invoke(clikan, ["a", "n_--task_test"]) 210 | assert result.exit_code == 0 211 | assert 'n_--task_test' in result.output 212 | assert version not in result.output 213 | 214 | 215 | # Limit on task name length tests 216 | 217 | def test_taskname_config_option(): 218 | runner = CliRunner() 219 | version_file = open(os.path.join('./', 'VERSION')) 220 | version = version_file.read().strip() 221 | path_to_config = str(pathlib.Path("./tests/taskname").resolve()) 222 | with runner.isolation( 223 | input=None, 224 | env={"CLIKAN_HOME": path_to_config}, 225 | color=False 226 | ): 227 | result = runner.invoke(clikan, []) 228 | assert result.exit_code == 0 229 | assert 'clikan' in result.output 230 | result = runner.invoke(clikan, ["a", "This is a long task name, more than 40 characters (66 to be exact)"]) 231 | assert result.exit_code == 0 232 | assert 'This is a long task name, more than 40 characters (66 to be exact)' in result.output 233 | 234 | 235 | def test_no_taskname_config_option(): 236 | runner = CliRunner() 237 | version_file = open(os.path.join('./', 'VERSION')) 238 | version = version_file.read().strip() 239 | path_to_config = str(pathlib.Path("./tests/no_taskname").resolve()) 240 | with runner.isolation( 241 | input=None, 242 | env={"CLIKAN_HOME": path_to_config}, 243 | color=False 244 | ): 245 | result = runner.invoke(clikan, []) 246 | assert result.exit_code == 0 247 | assert 'clikan' in result.output 248 | result = runner.invoke(clikan, ["a", "This is a long task name, more than 40 characters (66 to be exact)"]) 249 | assert result.exit_code == 0 250 | assert 'Brevity counts:' in result.output 251 | -------------------------------------------------------------------------------- /docs/icon-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitplummer/clikan/c296deb1f053a5ba28bb5d1fe13741c8e52df564/docs/icon-256x256.png -------------------------------------------------------------------------------- /docs/icon.graffle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitplummer/clikan/c296deb1f053a5ba28bb5d1fe13741c8e52df564/docs/icon.graffle -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Click>=8.0.1 2 | click-default-group>=1.2.2 3 | PyYAML>=5.3.1 4 | rich>=9.11.1 5 | setuptools>=69.1.1 6 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitplummer/clikan/c296deb1f053a5ba28bb5d1fe13741c8e52df564/screenshot.png -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | import os 3 | 4 | with open(os.path.join(os.getcwd(), 'VERSION')) as version_file: 5 | version = version_file.read().strip() 6 | 7 | with open("README.md", "r") as fh: 8 | long_description = fh.read() 9 | 10 | setup( 11 | author="Kit Plummer", 12 | author_email="kitplummer@gmail.com", 13 | name="clikan", 14 | url="https://github.com/kitplummer/clikan", 15 | version=version, 16 | description="Simple CLI-based Kanban board", 17 | long_description=long_description, 18 | long_description_content_type="text/markdown", 19 | py_modules=['clikan'], 20 | install_requires=[ 21 | 'Click', 22 | 'click-default-group', 23 | 'pyyaml', 24 | 'rich' 25 | ], 26 | entry_points=''' 27 | [console_scripts] 28 | clikan=clikan:clikan 29 | ''', 30 | classifiers=[ 31 | "License :: OSI Approved :: MIT License", 32 | "Programming Language :: Python :: 2.7", 33 | "Programming Language :: Python :: 3", 34 | "Environment :: Console" 35 | ] 36 | ) 37 | -------------------------------------------------------------------------------- /tests/no_repaint/.clikan.yaml: -------------------------------------------------------------------------------- 1 | clikan_data: tests/no_repaint/.clikan.dat 2 | repaint: false 3 | -------------------------------------------------------------------------------- /tests/no_repaint/donotdelete: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitplummer/clikan/c296deb1f053a5ba28bb5d1fe13741c8e52df564/tests/no_repaint/donotdelete -------------------------------------------------------------------------------- /tests/no_taskname/.clikan.yaml: -------------------------------------------------------------------------------- 1 | clikan_data: tests/no_taskname/.clikan.dat 2 | -------------------------------------------------------------------------------- /tests/no_taskname/donotdelete: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitplummer/clikan/c296deb1f053a5ba28bb5d1fe13741c8e52df564/tests/no_taskname/donotdelete -------------------------------------------------------------------------------- /tests/repaint/.clikan.yaml: -------------------------------------------------------------------------------- 1 | clikan_data: tests/repaint/.clikan.dat 2 | repaint: true 3 | -------------------------------------------------------------------------------- /tests/repaint/donotdelete: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitplummer/clikan/c296deb1f053a5ba28bb5d1fe13741c8e52df564/tests/repaint/donotdelete -------------------------------------------------------------------------------- /tests/taskname/.clikan.yaml: -------------------------------------------------------------------------------- 1 | clikan_data: tests/taskname/.clikan.dat 2 | limits: 3 | taskname: 80 4 | -------------------------------------------------------------------------------- /tests/taskname/donotdelete: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitplummer/clikan/c296deb1f053a5ba28bb5d1fe13741c8e52df564/tests/taskname/donotdelete --------------------------------------------------------------------------------