Skip to content

Commit 2cab5a3

Browse files
committed
rewriting with better type safety
1 parent 482352e commit 2cab5a3

17 files changed

+886
-822
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea
2+
.vscode
23

34
# Created by https://www.gitignore.io/api/python,vim,intellij
45
# Edit at https://www.gitignore.io/?templates=python,vim,intellij

Makefile

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
export TWINE_USERNAME=nonlogicaldev
2+
3+
.PHONY: install
14
install:
2-
pip install -r requirements.txt
3-
python setup.py install
5+
pip install -e .
6+
7+
.PHONY: deps
8+
deps:
9+
pipenv sync
10+
11+
.PHONY: dist
12+
dist:
13+
pipenv run python3 setup.py sdist
14+
15+
.PHONY: clean
16+
clean:
17+
-rm -rf build
18+
-rm -rf dist
19+
-rm -rf *.egg-info
20+
21+
pip.release: clean dist
22+
pipenv run twine upload --repository testpypi dist/*
23+
24+
pip.release.prod: clean dist
25+
pipenv run twine upload dist/*

Pipfile

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
[requires]
2+
python_version = "3"
3+
4+
[script]
5+
dotter = "python bin/dotter"
6+
17
[[source]]
28
name = "pypi"
39
url = "https://pypi.org/simple"
410
verify_ssl = true
511

612
[dev-packages]
7-
8-
[script]
9-
dotter = "python bin/dotter"
10-
11-
[requires]
12-
python_version = "3.7"
13+
twine = "*"
1314

1415
[packages]
1516
dotter = {editable = true,path = "."}

Pipfile.lock

+169-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+9-14
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,21 @@ dotter link
1313
## Usage Output:
1414

1515
### Root Command:
16-
```
17-
usage: dotter [-h] [--root ROOT_DIR] [--conf-dir CONF_DIR]
18-
{config,link,query,root} ...
1916

20-
A dotfile linker.
17+
```
18+
usage: dotter [-h] {version,link,config} ...
2119
22-
This utility creates a link farm from a data root to users home directory.
20+
A dotfile linker. This utility creates a link farm from a data root to users home directory.
2321
It's intended use is to keep dotfiles neatly organized and separated by topics.
2422
25-
Following ENV variables control the default behaviour:
26-
DOTTER_CONFIG_ROOT: Configuration root (where dotfiles live).
27-
DOTTER_OUTPUT_ROOT: Output root where the files will be linked to.
28-
29-
positional arguments:
30-
{config,link,query,root}
31-
3223
optional arguments:
3324
-h, --help show this help message and exit
34-
--root ROOT_DIR Alternative root location (for testing configuration)
35-
--conf-dir CONF_DIR Alternative configuration location (for testing configuration)
25+
26+
command:
27+
{version,link,config}
28+
version print version and exit
29+
link link dotfiles from $HOME/.config/dotter
30+
config query configuration values
3631
```
3732

3833
### Link Command:

bin/dotter

+12-10
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,28 @@
22
# -*- coding: utf-8 -*-
33

44
import sys
5-
import dotter
65
import argparse
76
import logging
87

8+
from dotter import App, SyncError
99

10-
log = logging.getLogger()
11-
log.addHandler(logging.StreamHandler(stream=sys.stderr))
12-
log.setLevel("DEBUG")
10+
__description__ = """
11+
A dotfile linker.
1312
13+
This utility creates a link farm from a data root to users home directory.
14+
It's intended use is to keep dotfiles neatly organized and separated by topics.
15+
"""
1416

1517
def main():
16-
parser = argparse.ArgumentParser(prog='dotter')
17-
18-
script = dotter.App(parser)
19-
18+
parser = argparse.ArgumentParser(
19+
prog='dotter',
20+
description=__description__,
21+
)
2022
try:
21-
return script.run(parser, parser.parse_args())
23+
return App.run(parser)
2224
except KeyboardInterrupt:
2325
return 1
24-
except Exception as e:
26+
except SyncError as e:
2527
parser.error(str(e))
2628
return 130
2729

0 commit comments

Comments
 (0)