Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/1.3.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
smallhadroncollider committed Mar 15, 2019
2 parents 5838c8c + b0439b5 commit 7a39fb7
Show file tree
Hide file tree
Showing 73 changed files with 2,719 additions and 2,640 deletions.
31 changes: 14 additions & 17 deletions .bin/build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver="lts-12.21"
resolver="lts-12.26"
ghcv="8.4.4"

branch=$(git rev-parse --abbrev-ref HEAD)
Expand All @@ -18,6 +18,10 @@ if [ -z "$1" ]; then
exit
fi

# make sure latest changes pushed to github
git push --all && git push --tags

# clean out previous build attempts
rm -rf .stack-work/install

# sort out releases directory
Expand Down Expand Up @@ -53,31 +57,24 @@ docker run -v "$PWD/releases/$1":/usr/src/app -w /usr/src/app debian dpkg-deb --

mv "releases/$1/taskell.deb" "releases/$1/taskell-$1_x86-64-linux.deb"


# Homebrew Pull Request
brew update
brew bump-formula-pr --url="https://github.com/smallhadroncollider/taskell/archive/$1.tar.gz"


# Release Template
rm -rf "releases/$1/taskell"

open "releases/$1"
open "https://github.com/smallhadroncollider/taskell/releases/new"


printf "
Release Template

---------------------------------------------

- changes...
echo "
-

### Installation

- Mac (Homebrew): \`brew install taskell\`
- Mac/Linux: download binary and place it in a directory in your \`\$PATH\` (e.g. \`/usr/local/bin\`)
- Debian (including Ubuntu): download the \`.deb\` file and run \`dpkg -i taskell-$1_x86-64-linux.deb\`
- Fedora: Run \`sudo dnf install ncurses-compat-libs\` then download and run binary as described above
- Fedora: Run \`sudo dnf install ncurses-compat-libs\` then download and run binary as described above" | pbcopy

echo "Release info copied to clipboard"

---------------------------------------------
"
# Homebrew Pull Request
brew update
brew bump-formula-pr --url="https://github.com/smallhadroncollider/taskell/archive/$1.tar.gz"
3 changes: 3 additions & 0 deletions .hindent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
indent-size: 4
line-length: 100
force-trailing-newline: false
16 changes: 16 additions & 0 deletions .stylish-haskell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
steps:
- simple_align:
cases: true
records: true

- imports:
align: group

- tabs:
spaces: 4

columns: 100

language_extensions:
- OverloadedStrings
- NoImplicitPrelude
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Please check the [roadmap.md](https://github.com/smallhadroncollider/taskell/blo

## Code

*Please use the `develop` branch as the base for any pull requests*

Anyone is welcome to contribute to the project. Check out [roadmap.md](https://github.com/smallhadroncollider/taskell/blob/develop/roadmap.md) for bugs and planned features if you're not sure where to start.

If you're planning on doing a big chunk of work it's probably best to [contact me](mailto:mark@smallhadroncollider.com) first to make sure someone isn't already working on it.
Expand All @@ -14,9 +16,9 @@ You'll probably want to get up to scratch with [Brick](https://github.com/jtdaug

### Style

This is my first Haskell project, so the style is often a bit inconsistent. I'm also probably not doing things in the most Haskelly manner (I still haven't used an Applicative anywhere). So, feel free to use whatever style you prefer. We can always refactor.
This was my first Haskell project, so the style has changed (improved?) as I've gone along.

I'm also very bad at comments: but please don't follow my example on that.
I'm now trying to use `pure` instead of `return`, `*>` instead of `>>`, and `<>` instead of `++`.

### Git

Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,21 @@ There are usually bottles (binaries) available. If these are not available for y

### Fedora

Run `sudo dnf install ncurses-compat-libs` then download and run binary as described below.
Not officially supported, but try running `sudo dnf install ncurses-compat-libs` then download and run the binary as described below. If that doesn't work you may need to build from scratch ([Cabal](#cabal)/[Stack](#stack)).

### Binaries

[A binary is available for Mac and Linux](https://github.com/smallhadroncollider/taskell/releases). Download it and copy it to a directory in your `$PATH` (e.g. `/usr/local/bin` or `/usr/bin`).
[A binary is available for Mac and Debian/Ubuntu](https://github.com/smallhadroncollider/taskell/releases). Download it and copy it to a directory in your `$PATH` (e.g. `/usr/local/bin` or `/usr/bin`).

### Cabal

You can install Taskell with `cabal`:

```bash
cabal install taskell
```

Make sure you run `cabal update` if you haven't run it recently.

### Stack

Expand Down Expand Up @@ -192,7 +202,9 @@ This would then show you a list of possible projects to import. Enter the number

## Configuration

You can edit Taskell's settings by editing `~/.taskell/config.ini`:
Taskell uses the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html), so it will look for an `$XDG_CONFIG_HOME` environmental variable and create a directory named `taskell` inside it. If this variable is not found it will create the `taskell` directory in `~/.config/`. (If you've been using Taskell since <= 1.3.5 then it will be in a `~/.taskell` directory, feel free to move this to the XDG directory.)

Taskell has a `config.ini` file:

```ini
[general]
Expand Down Expand Up @@ -241,7 +253,7 @@ subtask = "-"

### Theming

You can edit Taskell's colour-scheme by editing `~/.taskell/theme.ini`:
You can edit Taskell's colour-scheme by editing `theme.ini`:

```ini
[other]
Expand Down
12 changes: 6 additions & 6 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}

module Main where

import ClassyPrelude

import App (go)
import Events.State (create)
import IO.Taskell (Next(..), load)
import IO.Config (setup)
import App (go)
import IO.Config (setup)
import IO.Taskell (Next (..), load)

main :: IO ()
main = do
config <- setup
next <- runReaderT load config

case next of
Exit -> return ()
Output text -> putStrLn text
Exit -> pure ()
Output text -> putStrLn text
Load path lists -> go config $ create path lists
2 changes: 1 addition & 1 deletion docs/html/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: taskell
tagline: Command-line Kanban board/task managment
baseurl: ""
locale: "en"
version: 1.3.5
version: 1.3.6
destination: _site/public
exclude: [deployment, Capfile, log, Gemfile, Gemfile.lock]

Expand Down
11 changes: 6 additions & 5 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name: taskell
version: '1.3.5.0'
category: CLI
version: '1.3.6.0'
category: Command Line Tools
author: Mark Wales
maintainer: mark@smallhadroncollider.com
copyright: 2017 Mark Wales
copyright: 2019 Mark Wales
license: BSD3
synopsis: A command-line kanban board/task manager
description: Please see the README on GitHub at <https://github.com/smallhadroncollider/taskell#readme>
github: smallhadroncollider/taskell

extra-source-files:
- README.md
- templates/*

default-extensions:
- OverloadedStrings
Expand All @@ -19,8 +22,6 @@ dependencies:

library:
source-dirs: src
ghc-options:
- -O0
exposed-modules:
- App
- Events.State
Expand Down
4 changes: 3 additions & 1 deletion roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
* [ ] Text line breaks go a bit funny with multi-line descriptions
- Check times work no matter what timezone
- Import Issues from GitHub using labels
- Add custom key support
- Show filename somewhere
- Editable title?
> Use a `# Title` at top of file and display title somewhere in taskell
Expand All @@ -75,6 +74,8 @@
## In Progress

- Add custom key support
- Use proper error codes
- Performance with large files
> Becomes unusable with large files
* [x] Initially use debouncing to avoid writing too often
Expand Down Expand Up @@ -255,3 +256,4 @@
- Add ability to list GitHub projects
> Give an organisation or username and repo, list the possible projects to fetch - avoid having to look up the project ID manually first
- GitHub import should take pagination into account
- Use XDG spec for storing config files
112 changes: 60 additions & 52 deletions src/App.hs
Original file line number Diff line number Diff line change
@@ -1,55 +1,62 @@
{-# LANGUAGE NoImplicitPrelude #-}
module App (go) where

module App
( go
) where

import ClassyPrelude

import Control.Lens ((^.))

import Brick
import Graphics.Vty (Mode(BracketedPaste), outputIface, supportsMode, setMode)
import Graphics.Vty.Input.Events (Event(..))
import Graphics.Vty (Mode (BracketedPaste), outputIface, setMode, supportsMode)
import Graphics.Vty.Input.Events (Event (..))

import qualified Control.FoldDebounce as Debounce

import Data.Taskell.Lists (Lists)
import Data.Taskell.Date (currentDay)
import Events.Actions (event)
import Events.State (continue, countCurrent)
import Events.State.Types (State, path, mode, io, current, lists)
import Events.State.Types.Mode (Mode(..), ModalType(..), InsertMode(..), InsertType(..))
import IO.Config (Config, layout, generateAttrMap)
import IO.Taskell (writeData)
import UI.Draw (draw, chooseCursor)
import UI.Types (ResourceName(..))
import Data.Taskell.Date (currentDay)
import Data.Taskell.Lists (Lists)
import Events.Actions (event)
import Events.State (continue, countCurrent)
import Events.State.Types (State, current, io, lists, mode, path)
import Events.State.Types.Mode (InsertMode (..), InsertType (..), ModalType (..), Mode (..))
import IO.Config (Config, generateAttrMap, layout)
import IO.Taskell (writeData)
import UI.Draw (chooseCursor, draw)
import UI.Types (ResourceName (..))

type DebouncedMessage = (Lists, FilePath)

type DebouncedWrite = DebouncedMessage -> IO ()

type Trigger = Debounce.Trigger DebouncedMessage DebouncedMessage

-- store
store :: Config -> DebouncedMessage -> IO ()
store config (ls, pth) = writeData config ls pth

next :: DebouncedWrite -> State -> EventM ResourceName (Next State)
next send state = case state ^. io of
Just ls -> do
invalidateCache
liftIO $ send (ls, state ^. path)
Brick.continue $ Events.State.continue state
Nothing -> Brick.continue state

next send state =
case state ^. io of
Just ls -> do
invalidateCache
liftIO $ send (ls, state ^. path)
Brick.continue $ Events.State.continue state
Nothing -> Brick.continue state

-- debouncing
debounce :: Config -> State -> IO (DebouncedWrite, Trigger)
debounce config initial = do
trigger <- Debounce.new Debounce.Args {
Debounce.cb = store config,
Debounce.fold = \_ b -> b,
Debounce.init = (initial ^. lists, initial ^. path)
} Debounce.def
trigger <-
Debounce.new
Debounce.Args
{ Debounce.cb = store config
, Debounce.fold = \_ b -> b
, Debounce.init = (initial ^. lists, initial ^. path)
}
Debounce.def
let send = Debounce.send trigger
return (send, trigger)

pure (send, trigger)

-- cache clearing
clearCache :: State -> EventM ResourceName ()
Expand Down Expand Up @@ -77,46 +84,47 @@ clearList state = do
handleVtyEvent :: (DebouncedWrite, Trigger) -> State -> Event -> EventM ResourceName (Next State)
handleVtyEvent (send, trigger) previousState e = do
let state = event e previousState

case previousState ^. mode of
Search _ _ -> invalidateCache
(Modal MoveTo) -> clearAllTitles previousState
Search _ _ -> invalidateCache
(Modal MoveTo) -> clearAllTitles previousState
(Insert ITask ICreate _) -> clearList previousState
_ -> return ()

_ -> pure ()
case state ^. mode of
Shutdown -> liftIO (Debounce.close trigger) >> Brick.halt state
(Modal MoveTo) -> clearAllTitles state >> next send state
(Insert ITask ICreate _) -> clearList state >> next send state
_ -> clearCache previousState >> clearCache state >> next send state

handleEvent :: (DebouncedWrite, Trigger) -> State -> BrickEvent ResourceName e -> EventM ResourceName (Next State)
handleEvent _ state (VtyEvent (EvResize _ _ )) = invalidateCache >> Brick.continue state
handleEvent db state (VtyEvent ev) = handleVtyEvent db state ev
handleEvent _ state _ = Brick.continue state

Shutdown -> liftIO (Debounce.close trigger) *> Brick.halt state
(Modal MoveTo) -> clearAllTitles state *> next send state
(Insert ITask ICreate _) -> clearList state *> next send state
_ -> clearCache previousState *> clearCache state *> next send state

handleEvent ::
(DebouncedWrite, Trigger)
-> State
-> BrickEvent ResourceName e
-> EventM ResourceName (Next State)
handleEvent _ state (VtyEvent (EvResize _ _)) = invalidateCache *> Brick.continue state
handleEvent db state (VtyEvent ev) = handleVtyEvent db state ev
handleEvent _ state _ = Brick.continue state

-- | Runs when the app starts
-- Adds paste support
appStart :: State -> EventM ResourceName State
appStart state = do
vty <- getVtyHandle
let output = outputIface vty
when (supportsMode output BracketedPaste) $
liftIO $ setMode output BracketedPaste True
return state
when (supportsMode output BracketedPaste) $ liftIO $ setMode output BracketedPaste True
pure state

-- | Sets up Brick
go :: Config -> State -> IO ()
go config initial = do
attrMap' <- const <$> generateAttrMap
today <- currentDay
db <- debounce config initial
let app = App {
appDraw = draw (layout config) today
, appChooseCursor = chooseCursor
, appHandleEvent = handleEvent db
, appStartEvent = appStart
, appAttrMap = attrMap'
}
let app =
App
{ appDraw = draw (layout config) today
, appChooseCursor = chooseCursor
, appHandleEvent = handleEvent db
, appStartEvent = appStart
, appAttrMap = attrMap'
}
void (defaultMain app initial)
Loading

0 comments on commit 7a39fb7

Please sign in to comment.