diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-10-24 20:25:15 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-10-24 20:25:15 +0530 |
| commit | ff0daf7c5edb92e9e2361e9985996725bade9a85 (patch) | |
| tree | eea01a125f94bd1169e12ee55b0ff4df365ef92c | |
| parent | cae48d231a82cd451658e3745ab23e1a2057d406 (diff) | |
| download | daffm-ff0daf7c5edb92e9e2361e9985996725bade9a85.tar.gz daffm-ff0daf7c5edb92e9e2361e9985996725bade9a85.zip | |
Add build/install setup + fix read error for move command
Diffstat (limited to '')
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Makefile | 29 | ||||
| -rw-r--r-- | README.md | 11 | ||||
| -rw-r--r-- | docs/daffm.1 | 2 | ||||
| -rw-r--r-- | flake.nix | 5 | ||||
| -rw-r--r-- | justfile | 12 | ||||
| -rw-r--r-- | lib/Daffm/Action/Commands.hs | 9 | ||||
| -rw-r--r-- | lib/Daffm/State.hs | 2 |
8 files changed, 49 insertions, 23 deletions
@@ -1,3 +1,5 @@ result dist-newstyle/ dist-lib/* +daffm-build/ +daffm.tar.gz diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..699b9dd --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +.POSIX: + +PREFIX = /usr/local + +all: build + +build: + cabal build + +dist: + mkdir -p daffm-build + make PREFIX=daffm-build install + cp -R LICENSE daffm-build + tar -cf - daffm-build | gzip > daffm.tar.gz + rm -rf daffm-build + +install: + cabal install -g -O2 --install-method=copy --overwrite-policy=always --installdir="$(PREFIX)/bin/" + install -Dm644 "./docs/daffm.1" "$(PREFIX)/share/man/man1/daffm.1" + +uninstall: + rm -f "$(PREFIX)/bin/daffm" + rm -f "$(PREFIX)/share/man/man1/daffm.1" + +# Generate markdown doc from manpage +doc: + pandoc -f man -t markdown docs/daffm.1 -o docs/daffm.md + +.PHONY: build install doc @@ -1,12 +1,17 @@ # Daffm Dumb as fuck file manager is a minimal tui file manager with the goal of not being a file manager. At its core, it only provides a directory browser, providing ways to conviniently run shell commands to manage your files via keybinds and command line input. -  ## Install -- Clone the repo and build it: `cabal build daffm` or `nix build` -- Nix flakes users can install it as a flake: `github:phenax/daffm#daffm` +### Nix users +- This repo can be installed as a nix flake: `github:phenax/daffm#daffm` +- OR clone the repo and build it: `nix build` +### Normals (requires cabal) +- Clone the repo +- `make install` to install it on your system (installs in `/usr/local` by default) +- OR `make PREFIX=/install/path install` to install it inside `/install/path` directory +- `make uninstall` to uninstall it ## Usage Run `man daffm` to see the manual -> [./docs/daffm.md](./docs/daffm.md) diff --git a/docs/daffm.1 b/docs/daffm.1 index 8fdbcde..25f26e8 100644 --- a/docs/daffm.1 +++ b/docs/daffm.1 @@ -1,4 +1,4 @@ -.TH DAFFM 1 daffm\-VERSION +.TH DAFFM 1 daffm\-0.1.0 .SH NAME daffm \- dumb as fuck file manager .SH SYNOPSIS @@ -33,7 +33,10 @@ pkg-config ]; - devPackages = with pkgs; [ just pandoc ]; + devPackages = with pkgs; [ + pandoc + gnumake + ]; in { haskellProjects.default = { inherit projectRoot; diff --git a/justfile b/justfile deleted file mode 100644 index e11c187..0000000 --- a/justfile +++ /dev/null @@ -1,12 +0,0 @@ -default: - @just --choose - -run *args: - cabal run daffm -- {{args}} - -test *args: - cabal test {{args}} - -doc: - pandoc -f man -t markdown docs/daffm.1 -o docs/daffm.md - diff --git a/lib/Daffm/Action/Commands.hs b/lib/Daffm/Action/Commands.hs index 669ff3c..c77a9fc 100644 --- a/lib/Daffm/Action/Commands.hs +++ b/lib/Daffm/Action/Commands.hs @@ -20,6 +20,7 @@ import Data.Maybe (fromMaybe) import qualified Data.Text as Text import qualified Data.Text.IO as Text import qualified System.Process as Proc +import Text.Read (readMaybe) runCmdline :: AppEvent () runCmdline = do @@ -53,14 +54,14 @@ parseCommand cmd = mkCmd . splitCmdArgs $ trimStart cmd ("search", term) -> Just $ CmdSearch $ trim term ("search-next", _) -> Just $ CmdSearchNext 1 ("search-prev", _) -> Just $ CmdSearchNext (-1) - ("move", Text.stripPrefix "$" -> Just _) -> Just $ CmdMove MoveToEnd - ("move", Text.stripPrefix "+" -> Just inc) -> Just . CmdMove . MoveDown . read $ Text.unpack inc - ("move", Text.stripPrefix "-" -> Just inc) -> Just . CmdMove . MoveUp . read $ Text.unpack inc - ("move", pos) -> Just . CmdMove . MoveTo . read $ Text.unpack pos ("map", Text.break isSpace -> (keysraw, cmdraw)) -> do keys <- parseKeySequence keysraw cmd' <- parseCommand $ trimStart cmdraw pure $ CmdKeymapSet keys cmd' + ("move", Text.stripPrefix "$" -> Just _) -> Just $ CmdMove MoveToEnd + ("move", Text.stripPrefix "+" -> Just inc) -> Just . CmdMove . MoveDown . read $ Text.unpack inc + ("move", Text.stripPrefix "-" -> Just inc) -> Just . CmdMove . MoveUp . read $ Text.unpack inc + ("move", readMaybe . Text.unpack -> Just pos) -> Just . CmdMove . MoveTo $ pos _ -> Nothing readCommandLines' :: Text.Text -> IO [Text.Text] diff --git a/lib/Daffm/State.hs b/lib/Daffm/State.hs index cd8d6ec..6d7f6ea 100644 --- a/lib/Daffm/State.hs +++ b/lib/Daffm/State.hs @@ -3,13 +3,11 @@ {-# HLINT ignore "Redundant multi-way if" #-} module Daffm.State where -import Brick (suspendAndResume') import qualified Brick.Widgets.Edit as Editor import qualified Brick.Widgets.List as L import Control.Applicative ((<|>)) import Control.Exception (try) import Control.Monad (filterM, forM) -import qualified Debug.Trace as Debug import Daffm.Types import Daffm.Utils (trim) import Data.List (findIndex, sortBy) |
