Update build

This commit is contained in:
2026-04-25 02:36:47 -07:00
parent dd8bbf2277
commit d10ed0daab
4 changed files with 51 additions and 24 deletions

View File

@@ -0,0 +1,27 @@
#compdef license-tool
_license-tool_files() {
# system dir
local system_dir="/usr/share/license-tool/"
for file in "${system_dir}"**(N); do
compadd -X "[system]" "${file#"${system_dir}"}"
done
# user dir
if [[ -v XDG_CONFIG_HOME ]]; then
local user_dir="${XDG_CONFIG_HOME}/license-tool/"
else
local user_dir="${HOME}/.config/license-tool/"
fi
for file in "${user_dir}"**(N); do
compadd -X "[user]" "${file#"${user_dir}"}"
done
}
_arguments -w \
'-h[print help]' \
'-l[list installed licenses]' \
'-s[only search the system license directory]' \
'-u[only search the user license directory]' \
'-o[output file]:output:_files' \
':license:_license-tool_files'

View File

@@ -1,4 +1,4 @@
cabal-version: 2.2 cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.38.1. -- This file has been generated from package.yaml by hpack version 0.38.1.
-- --
@@ -6,11 +6,13 @@ cabal-version: 2.2
name: license-tool name: license-tool
version: 0.1.0.0 version: 0.1.0.0
synopsis: Tool for generating LICENSE files
description: Please see the README at <https://git.zander.im/Zander671/license-tool> description: Please see the README at <https://git.zander.im/Zander671/license-tool>
category: Development
author: Alexander Rosenberg author: Alexander Rosenberg
maintainer: zanderpkg@pm.me maintainer: zanderpkg@pm.me
copyright: 2026 Alexander Rosenberg copyright: 2026 Alexander Rosenberg
license: BSD-3-Clause license: GPL-3
license-file: LICENSE license-file: LICENSE
build-type: Simple build-type: Simple
extra-source-files: extra-source-files:
@@ -25,13 +27,11 @@ executable license-tool
main-is: Main.hs main-is: Main.hs
other-modules: other-modules:
Paths_license_tool Paths_license_tool
autogen-modules:
Paths_license_tool
hs-source-dirs: hs-source-dirs:
src src
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
build-depends: build-depends:
base >=4.7 && <5 base >=4.7 && <5
, directory , directory >=1.3.8 && <1.4
, filepath , filepath >=1.5.4 && <1.6
default-language: Haskell2010 default-language: Haskell2010

View File

@@ -1,27 +1,22 @@
name: license-tool name: license-tool
version: 0.1.0.0 version: 0.1.0.0
license: BSD-3-Clause license: GPL-3
author: "Alexander Rosenberg" author: Alexander Rosenberg
maintainer: "zanderpkg@pm.me" maintainer: zanderpkg@pm.me
copyright: "2026 Alexander Rosenberg" copyright: 2026 Alexander Rosenberg
synopsis: Tool for generating LICENSE files
category: Development
extra-source-files: extra-source-files:
- README.md - README.md
- licenses/* - licenses/*
# Metadata used when publishing your package
# synopsis: Short description of your package
# category:
# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description: Please see the README at <https://git.zander.im/Zander671/license-tool> description: Please see the README at <https://git.zander.im/Zander671/license-tool>
dependencies: dependencies:
- base >= 4.7 && < 5 - base >= 4.7 && < 5
- directory - directory >= 1.3.8 && < 1.4
- filepath - filepath >= 1.5.4 && < 1.6
ghc-options: ghc-options:
- -Wall - -Wall

View File

@@ -5,7 +5,7 @@ import Control.Monad
import Data.Functor import Data.Functor
import Data.List (isInfixOf, isSuffixOf) import Data.List (isInfixOf, isSuffixOf)
import System.Directory (listDirectory) import System.Directory (listDirectory)
import System.Environment (getArgs, getEnv) import System.Environment (getArgs, getEnv, lookupEnv)
import System.IO import System.IO
import System.IO.Error import System.IO.Error
@@ -13,12 +13,12 @@ import System.IO.Error
defaultOutfile :: String defaultOutfile :: String
defaultOutfile = "LICENSE" defaultOutfile = "LICENSE"
defaultUserLicenseDirName :: String
defaultUserLicenseDirName = "license-tool"
defaultSystemLicenseDir :: String defaultSystemLicenseDir :: String
defaultSystemLicenseDir = "/usr/share/license-tool" defaultSystemLicenseDir = "/usr/share/license-tool"
defaultUserLicenseRelDir :: String
defaultUserLicenseRelDir = ".config/license-tool"
-- Argument parsing -- Argument parsing
data SearchMode = SystemOnly | UserOnly | UserThenSystem data SearchMode = SystemOnly | UserOnly | UserThenSystem
@@ -71,8 +71,13 @@ normalizeDirectory :: String -> String
normalizeDirectory s = if "/" `isSuffixOf` s then s else s ++ "/" normalizeDirectory s = if "/" `isSuffixOf` s then s else s ++ "/"
userLicenseDir :: IO String userLicenseDir :: IO String
userLicenseDir = userHomeDir <&> (++ defaultUserLicenseRelDir) userLicenseDir = xdgConfigHome <&> (++ defaultUserLicenseDirName)
where where
xdgConfigHome :: IO String
xdgConfigHome =
(lookupEnv "XDG_CONFIG_HOME")
>>= maybe userHomeDir (return . normalizeDirectory)
userHomeDir :: IO String userHomeDir :: IO String
userHomeDir = getEnv "HOME" <&> normalizeDirectory userHomeDir = getEnv "HOME" <&> normalizeDirectory