From ff0daf7c5edb92e9e2361e9985996725bade9a85 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 24 Oct 2025 20:25:15 +0530 Subject: Add build/install setup + fix read error for move command --- .gitignore | 2 ++ Makefile | 29 +++++++++++++++++++++++++++++ README.md | 11 ++++++++--- docs/daffm.1 | 2 +- flake.nix | 5 ++++- justfile | 12 ------------ lib/Daffm/Action/Commands.hs | 9 +++++---- lib/Daffm/State.hs | 2 -- 8 files changed, 49 insertions(+), 23 deletions(-) create mode 100644 Makefile delete mode 100644 justfile diff --git a/.gitignore b/.gitignore index 1198af0..ceefb27 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/README.md b/README.md index 61d0cf1..cf9bb07 100644 --- a/README.md +++ b/README.md @@ -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. - ![screenshot](./media/screenshot.jpg) ## 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 diff --git a/flake.nix b/flake.nix index 68140fc..8027657 100644 --- a/flake.nix +++ b/flake.nix @@ -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) -- cgit v1.3.1