mirror of https://github.com/Marcusk19/dotctl
Work (#13)
* use config for dotfile path, add some makefile scripts * update README * add unit test for link command * fixing cipull/16/head
parent
2060833611
commit
9ef61b2626
@ -0,0 +1,10 @@
|
|||||||
|
clean:
|
||||||
|
rm -rf test/bender_test 2> /dev/null
|
||||||
|
rm -rf tmp 2> /dev/null
|
||||||
|
|
||||||
|
sandbox:
|
||||||
|
mkdir -p ./tmp/ 2> /dev/null
|
||||||
|
cp -r ~/.config/ ./tmp/config 2> /dev/null
|
||||||
|
|
||||||
|
unit-test:
|
||||||
|
TESTING=true go test -v ./test
|
||||||
@ -1,15 +1,36 @@
|
|||||||
# Bender
|
# Bender
|
||||||

|

|
||||||
|
|
||||||
A general purpose CLI tool.
|
A cli tool to manage your dotfiles
|
||||||
|
## About
|
||||||
|
Bender is a tool to help you easily manage your dotfiles and sync them across separate machines using
|
||||||
|
git. It aims to abstract away the manual effort of symlinking your dotfiles to config directories and
|
||||||
|
updating them with git.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
- TBD
|
- TBD
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
use pretty command to get whitespace for special characters like `\n` and `\t`
|
|
||||||
|
|
||||||
e.g.
|
|
||||||
```bash
|
```bash
|
||||||
bender pretty example.txt
|
# init sets up the config file and directory to hold all dotfiles
|
||||||
|
bender init --dotfile-path=/path/to/dotfile/repo
|
||||||
|
# add a config directory for bender to track
|
||||||
|
bender add /.config/nvim
|
||||||
|
# create symlinks
|
||||||
|
bender link
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Development
|
||||||
|
It's preferable to create a temporary directory and copy your system's config
|
||||||
|
directory over to avoid making undesirable changes to your system.
|
||||||
|
A couple of useful makefile scripts exist to set up and tear down this.
|
||||||
|
It will create a testing directory in `./tmp/config` and copy your system configs
|
||||||
|
over.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make sandbox # creates the directory and copies over from ~/.config
|
||||||
|
make clean # removes directory
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,54 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Marcusk19/bender/cmd"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func TestLinkCommand(t *testing.T) {
|
||||||
|
setUpTesting()
|
||||||
|
bender := cmd.RootCmd
|
||||||
|
actual := new(bytes.Buffer)
|
||||||
|
|
||||||
|
bender.SetOut(actual)
|
||||||
|
bender.SetErr(actual)
|
||||||
|
bender.SetArgs([]string{"link"})
|
||||||
|
|
||||||
|
bender.Execute()
|
||||||
|
|
||||||
|
homedir := os.Getenv("HOME")
|
||||||
|
someconfig := filepath.Join(homedir, ".config/someconfig/")
|
||||||
|
somedot := filepath.Join(homedir, ".dotfiles/someconfig/")
|
||||||
|
|
||||||
|
expected := fmt.Sprintf("%s,%s", someconfig, somedot)
|
||||||
|
|
||||||
|
assert.Equal(t, expected, actual.String(), "actual differs from expected")
|
||||||
|
|
||||||
|
tearDownTesting()
|
||||||
|
}
|
||||||
|
|
||||||
|
func setUpTesting() {
|
||||||
|
fs := cmd.FileSystem
|
||||||
|
homedir := os.Getenv("HOME")
|
||||||
|
fs.MkdirAll(filepath.Join(homedir, ".dotfiles/bender"), 0755)
|
||||||
|
fs.Create(filepath.Join(homedir, ".dotfiles/bender/config"))
|
||||||
|
fs.MkdirAll(filepath.Join(homedir, ".dotfiles/someconfig/"), 0755)
|
||||||
|
|
||||||
|
viper.Set("dotfile-path", filepath.Join(homedir, ".dotfiles"))
|
||||||
|
viper.Set("someconfig", filepath.Join(homedir, ".config/someconfig/"))
|
||||||
|
viper.Set("testing", true)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func tearDownTesting() {
|
||||||
|
fs := cmd.FileSystem
|
||||||
|
fs.RemoveAll("bender_test/")
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue