Manpage, remove works, licence added
This commit is contained in:
parent
a9f9f7dc28
commit
bb41d6c059
7 changed files with 174 additions and 27 deletions
19
LICENSE
Normal file
19
LICENSE
Normal file
|
@ -0,0 +1,19 @@
|
|||
MIT License Copyright (c) <year> <copyright holders>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
Makefile
19
Makefile
|
@ -2,20 +2,24 @@
|
|||
# worldedit
|
||||
#
|
||||
# @file
|
||||
# @version 0.1
|
||||
# @version 0.3
|
||||
|
||||
SRC = *.nim
|
||||
SRCDIR = src
|
||||
BIN = worldedit
|
||||
MAN = worldedit.1
|
||||
PREFIX := /usr/local
|
||||
DESTDIR :=
|
||||
|
||||
.PHONY: default
|
||||
default: release
|
||||
|
||||
.PHONY: all
|
||||
all: pretty release man docs
|
||||
|
||||
.PHONY: release
|
||||
release:
|
||||
nimble build '--cc:clang -d:release'
|
||||
nimble build '--cc:clang -d:release' -y
|
||||
|
||||
.PHONY: debug
|
||||
debug:
|
||||
|
@ -35,7 +39,7 @@ run:
|
|||
|
||||
.PHONY: docs
|
||||
docs:
|
||||
nim doc ${SRCDIR}/${SRC}
|
||||
nimble doc ${SRCDIR}/${SRC}
|
||||
|
||||
.PHONY: pretty
|
||||
pretty:
|
||||
|
@ -47,6 +51,15 @@ test:
|
|||
|
||||
.PHONY: install
|
||||
install:
|
||||
install -Dm755 ${MAN} $(DESTDIR)$(PREFIX)/man/${MAN}
|
||||
install -Dm755 ${BIN} $(DESTDIR)$(PREFIX)/bin/${BIN}
|
||||
|
||||
.PHONY: man
|
||||
man:
|
||||
pandoc worldedit.1.md -s -t man | gzip > worldedit.1
|
||||
|
||||
.PHONY: testman
|
||||
testman: man
|
||||
cat worldedit.1 | man -l -
|
||||
|
||||
# end
|
||||
|
|
15
README.md
15
README.md
|
@ -10,6 +10,17 @@ Emulating Gentoo's world files and sets for other package managers.
|
|||
Hint: Install Nim with Choosenim ([Github](https://github.com/dom96/choosenim))
|
||||
|
||||
## Installation
|
||||
Arch Linux (AUR)
|
||||
|
||||
```bash
|
||||
pacman -S --needed git base-devel
|
||||
git clone https://aur.archlinux.org/worldedit-git.git
|
||||
cd worldedit
|
||||
makepkg -si
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
Directly with Nimble (with url)
|
||||
|
||||
```bash
|
||||
|
@ -43,7 +54,7 @@ Options:
|
|||
-h, --help Show this screen.
|
||||
-v, --version Show version.
|
||||
--worldfile file Worldfile to use
|
||||
--init Initializes a worldfile if none are provided
|
||||
--init Initializes a worldfile if it does not exist
|
||||
--list-command=<command> List all packages command
|
||||
--install-command=<command> Package install command
|
||||
--remove-command=<command> Package remove command
|
||||
|
@ -51,7 +62,7 @@ Options:
|
|||
--sync Add/remove packages to match the worldfile
|
||||
--diff Lists the packages that are added/removed
|
||||
--install=<package> Installs a package and appends to the worldfile
|
||||
--remove=<package> Removes a package and deletes the entry in the worldfile [WIP]
|
||||
--remove=<package> Removes a package and deletes the entry in the worldfile
|
||||
--bash Outputs commands that can be piped into bash
|
||||
--orphans Removes things marked as orphans from your system
|
||||
```
|
||||
|
|
|
@ -10,7 +10,7 @@ import strutils
|
|||
import typetraits
|
||||
|
||||
let doc = """
|
||||
Worldedit.
|
||||
worldedit - Emulating Gentoo's world files and sets for other package managers.
|
||||
|
||||
Usage:
|
||||
worldedit [options]
|
||||
|
@ -19,7 +19,7 @@ Options:
|
|||
-h, --help Show this screen.
|
||||
-v, --version Show version.
|
||||
--worldfile file Worldfile to use
|
||||
--init Initializes a worldfile if none are provided
|
||||
--init Initializes a worldfile if it does not exist
|
||||
--list-command=<command> List all packages command
|
||||
--install-command=<command> Package install command
|
||||
--remove-command=<command> Package remove command
|
||||
|
@ -27,7 +27,7 @@ Options:
|
|||
--sync Add/remove packages to match the worldfile
|
||||
--diff Lists the packages that are added/removed
|
||||
--install=<package> Installs a package and appends to the worldfile
|
||||
--remove=<package> Removes a package and deletes the entry in the worldfile [WIP]
|
||||
--remove=<package> Removes a package and deletes the entry in the worldfile
|
||||
--bash Outputs commands that can be piped into bash
|
||||
--orphans Removes things marked as orphans from your system
|
||||
"""
|
||||
|
@ -41,24 +41,33 @@ proc clean(input: seq[string]): seq[string] =
|
|||
|
||||
proc readWorldFile(input: string): seq[string] =
|
||||
# Recursively reads in worldfiles, and sets
|
||||
let packageFile = read_file(input).split
|
||||
var packageList: seq[string]
|
||||
try:
|
||||
let packageFile = read_file(input).split
|
||||
var packageList: seq[string]
|
||||
|
||||
for i in packageFile:
|
||||
if i.startsWith("@"): # is a set name
|
||||
let setList = readWorldFile(
|
||||
joinpath(input.parentDir, i.strip(chars = {'@'}))
|
||||
)
|
||||
for i in packageFile:
|
||||
if i.startsWith("@"): # is a set name
|
||||
try:
|
||||
let setList = readWorldFile(
|
||||
joinpath(input.parentDir, i.strip(chars = {'@'}))
|
||||
)
|
||||
packageList = concat(packageList, setList)
|
||||
except:
|
||||
fmt"Could not read {i} file.".echo
|
||||
quit(QuitFailure)
|
||||
|
||||
packageList = concat(packageList, setList)
|
||||
elif i.startsWith("#"): # is a comment
|
||||
discard
|
||||
elif not i.isEmptyOrWhitespace: # is a package name
|
||||
packageList.insert(i)
|
||||
elif i.startsWith("#"): # is a comment
|
||||
discard
|
||||
elif not i.isEmptyOrWhitespace: # is a package name
|
||||
packageList.insert(i)
|
||||
|
||||
# filter out empty/whitespace, then dedupe on return
|
||||
packageList = packageList.clean
|
||||
return packageList.sorted
|
||||
except:
|
||||
fmt"Could not read {input} file.".echo
|
||||
quit(QuitFailure)
|
||||
|
||||
# filter out empty/whitespace, then dedupe on return
|
||||
packageList = packageList.clean
|
||||
return packageList.sorted
|
||||
|
||||
proc generatePackageList(listCommand: string): seq[string] =
|
||||
# Generates a newline seperated list of packages, and returns it
|
||||
|
@ -99,7 +108,7 @@ proc createWorldFile(worldFile: string, listCommand: string) =
|
|||
when isMainModule:
|
||||
var config = getEnvConfig(Worldedit)
|
||||
|
||||
let args = docopt(doc, version = "Renamer 0.2")
|
||||
let args = docopt(doc, version = "Renamer 0.3")
|
||||
if args["--worldfile"]: config.world = $args["--worldfile"]
|
||||
if args["--list-command"]: config.listCommand = $args["--list-command"]
|
||||
if args["--install-command"]: config.installCommand = $args["--install-command"]
|
||||
|
@ -149,8 +158,15 @@ when isMainModule:
|
|||
let newWorld = (world & config.install.split).clean.join(sep = "\n")
|
||||
writeFile(config.world, newWorld)
|
||||
elif not config.remove.isEmptyOrWhitespace:
|
||||
#TODO Find and remove from worldfile
|
||||
installRemove(config.removeCommand, @[config.remove])
|
||||
var world = config.world.read_file.split
|
||||
let toDelete = find(world, config.remove)
|
||||
if toDelete != -1:
|
||||
delete(world, toDelete)
|
||||
let newWorld = world.clean.join(sep = "\n")
|
||||
writeFile(config.world, newWorld)
|
||||
installRemove(config.removeCommand, @[config.remove])
|
||||
else:
|
||||
fmt"Could not find {config.remove} in worldfile.".echo
|
||||
elif config.bash:
|
||||
let ic = config.installCommand & " " & added.join(sep = " ")
|
||||
let rc = config.removeCommand & " " & removed.join(sep = " ")
|
||||
|
|
BIN
worldedit.1
Normal file
BIN
worldedit.1
Normal file
Binary file not shown.
88
worldedit.1.md
Normal file
88
worldedit.1.md
Normal file
|
@ -0,0 +1,88 @@
|
|||
% worldedit(1)
|
||||
|
||||
# Name
|
||||
worldedit - Emulating Gentoo's world files and sets for other package managers.
|
||||
|
||||
# Synopsis
|
||||
worldedit [options]
|
||||
|
||||
# DESCRIPTION
|
||||
Recreates Gentoo's world files for other distros. It hooks the native package manager
|
||||
to set which packages are explicitly installed, and leaves the dependency resolving up
|
||||
to the package manager. Any package manager that can create a list of packages installed
|
||||
by package name, newline separated, and keep track of packages explicitly installed, as
|
||||
opposed to dependencies should be compatible with this application.
|
||||
|
||||
# OPTIONS
|
||||
**-h**, **--help**
|
||||
: Show the help screen.
|
||||
|
||||
**-v**, **--version**
|
||||
: Show version.
|
||||
|
||||
**--worldfile**=file
|
||||
: Worldfile to use
|
||||
|
||||
**--init**
|
||||
: Initializes a worldfile if it does not exist
|
||||
|
||||
**--list-command**
|
||||
: List all packages command
|
||||
|
||||
**--install-command**
|
||||
: Package install command
|
||||
|
||||
**--remove-command**
|
||||
: Package remove command
|
||||
|
||||
**--orphans-command**
|
||||
: Orphans remove command
|
||||
|
||||
**--sync**
|
||||
: Add/remove packages to match the worldfile
|
||||
|
||||
**--diff**
|
||||
: Lists the packages that are added/removed
|
||||
|
||||
**--install**=<package>
|
||||
: Installs a package and appends to the worldfile
|
||||
|
||||
**--remove**=<package>
|
||||
: Removes a package and deletes the entry in the worldfile
|
||||
|
||||
**--bash**
|
||||
: Outputs commands that can be piped into bash
|
||||
|
||||
**--orphans**
|
||||
: Removes things marked as orphans from your system
|
||||
|
||||
# EXIT STATUS
|
||||
**0**
|
||||
: Success
|
||||
|
||||
**1**
|
||||
: Failure
|
||||
|
||||
# BUGS
|
||||
https://github.com/kdb424/worldedit/issues
|
||||
|
||||
# COPYRIGHT
|
||||
MIT License Copyright (c) 2021 Kyle Brown
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,6 +1,6 @@
|
|||
# Package
|
||||
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
author = "Kyle Brown"
|
||||
description = "Gentoo's world file, but everywhere."
|
||||
license = "MIT"
|
||||
|
|
Loading…
Add table
Reference in a new issue