From f0199cf618af7c4bcc3737e98948d2f7ceeb02e6 Mon Sep 17 00:00:00 2001 From: mapperr Date: Wed, 18 Dec 2019 18:23:15 +0100 Subject: [PATCH] Add labels to board view --- README.md | 23 +++++++++++++++-------- trullo.py | 23 ++++++++++++++++------- trullo/printer.py | 7 +++++-- trullo/usecases.py | 3 +++ 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index dcafa7a..1620d26 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,11 @@ A dumb trello cli with shortcuts. ## Setup -Get the repo and run `pipenv install` in it +Get the repo and run `pipenv install` in it. You don't have pipenv installed? Shame on you.\ ([Here](https://pipenv.readthedocs.io/en/latest/install/#pragmatic-installation-of-pipenv) -is how to can get it, but usually is a `pip install --user pipenv`) +is how you can get it, but usually is a `pip install --user pipenv`) Yeah, I know you want a binary, I will package this thing, bear it for now. @@ -20,6 +20,10 @@ Authenticate yourself by putting these variables in you environment: Go get them on [trello](https://trello.com/app-key)! +Now link the `trl` script in your `PATH`. +It's a bash script that wraps the underneath python call. +Feel free to hack it or use something else. + Aaaand, that's it, you are good to go. @@ -54,14 +58,13 @@ Here is the usage (check `trl -h` too): ## Shortcuts -Shortcuts are derived from boards and cards short urls and from lists ids -(lists does not have short urls) and are as short as possible. - -So to move a card to a list you get something like this: +Shortcuts are derived from boards and cards names and short urls +and from lists names and ids (lists does not have short urls). - trl c j0 m e +So to move the card *Architecture design* to the list *Done* +you get something like this: -`j0` is the card shortcut and `e` is the list shortcut + trl c arch m done Oh, everything is kept lowercase, holding shift is a pain in the ass. @@ -71,3 +74,7 @@ Oh, everything is kept lowercase, holding shift is a pain in the ass. I know, It's nothing fancy, I just started it to check some trello stuff directly in the terminal, and eventually edit them. + +### Development board + +- https://trello.com/b/fuK3ff2z diff --git a/trullo.py b/trullo.py index fb44958..018fb1c 100644 --- a/trullo.py +++ b/trullo.py @@ -1,6 +1,7 @@ """Trullo usage: + trl o trl b [] trl l [...] trl ll @@ -13,6 +14,9 @@ usage: commands: + o + open trello in your browser + b [] shows the boards you can access with board_shortcut you can select the board you want to work with @@ -44,6 +48,9 @@ env: you can obtain those values here: https://trello.com/app-key + +trello development board: https://trello.com/b/fuK3ff2z + """ import logging import pprint @@ -55,7 +62,6 @@ from trullo.printer import Printer from trullo.shortener import Shortener from trullo.tclient import TClient from trullo.tconfig import TConfig -# logging.basicConfig(level=logging.DEBUG) from trullo.usecases import Usecases logging.basicConfig(level=logging.INFO) @@ -83,26 +89,29 @@ if __name__ == '__main__': pp = pprint.PrettyPrinter(indent=4) pp.pprint(tclient.get(api_path)) - if args['b']: + elif args['o']: + usecases.open_trello_in_browser() + + elif args['b']: if args['']: board_shortcut = args[''] usecases.select_board(board_shortcut) else: usecases.print_board_list() - # stuff that works only if a board is selected - if not args['b'] and selected_board_name is None: + # below are stuffs that works only if a board is selected + elif not args['b'] and selected_board_name is None: print(f'first select a board with `trl b`') exit(1) - if args['ll']: + elif args['ll']: usecases.print_board_lists() - if args['l']: + elif args['l']: list_shortcuts = args[''] usecases.print_lists(list_shortcuts) - if args['c']: + elif args['c']: new_command = args['n'] if new_command: target_list_shortcut = args[''] diff --git a/trullo/printer.py b/trullo/printer.py index de382cf..8b9e9ae 100644 --- a/trullo/printer.py +++ b/trullo/printer.py @@ -36,8 +36,11 @@ class Printer: f"[{list_.raw_data['id'].lower()}]") for card in board.cards: if card.raw_data['idList'] == list_.id: - print(f"\t[{card.raw_data['shortLink'].lower()}] " - f"{card.raw_data['name']}") + card_output = f"\t[{card.raw_data['shortLink'].lower()}] " + for raw_label in card.raw_data['labels']: + card_output += f'({raw_label["name"]}) ' + card_output += f"{card.raw_data['name']}" + print(card_output) print() @staticmethod diff --git a/trullo/usecases.py b/trullo/usecases.py index 823a9b5..f05f8cd 100644 --- a/trullo/usecases.py +++ b/trullo/usecases.py @@ -34,6 +34,9 @@ class Usecases: return selected_board_id, selected_board_name return None, None + def open_trello_in_browser(self): + subprocess.Popen(['xdg-open', 'https://trello.com']) + def print_board_list(self): boards = self.tclient.get_boards() self.printer.print_boards(boards) -- 2.34.2