Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moba1/dotsetup
golang library for dotfiles setup
https://github.com/moba1/dotsetup
cc0 dotfiles golang golang-library linux public-domain
Last synced: about 1 month ago
JSON representation
golang library for dotfiles setup
- Host: GitHub
- URL: https://github.com/moba1/dotsetup
- Owner: moba1
- License: cc0-1.0
- Created: 2021-07-05T16:25:32.000Z (over 3 years ago)
- Default Branch: develop
- Last Pushed: 2022-08-20T13:11:30.000Z (over 2 years ago)
- Last Synced: 2024-10-25T01:45:05.041Z (3 months ago)
- Topics: cc0, dotfiles, golang, golang-library, linux, public-domain
- Language: Go
- Homepage:
- Size: 65.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![test](https://github.com/moba1/dotsetup/actions/workflows/test.yml/badge.svg)
# dotsetup
dotsetup is a library for seting up dotfiles.
This library use `sudo` & `curl` command internally.
This library setup dotfiles by combining `task` and finally executing all tasks..
`task` represents execution entity corresponding one line shell command.
For exmaple, `dotsetup.Curl` corresponds to `curl` command.## Quick examples
This sample executes series of process to
1. install `sample-package`
1. fetch `index.html` from `example.com````go
import (
"github.com/moba1/dotsetup/v3"
"log"
)// set `sample-package` installing task
sp := dotsetup.Package{
Name: "sample-package"
}
// set fetching index.html to /tmp
c := dotsetup.Curl{
Args: []string{"-o", "/tmp/index.html", "https://example.com/index.html"}
}
// execute all tasks
// order: sp -> c
s := dotsetup.NewScript([]dotsetup.Task{sp, c})
// enable debug mode
s.Debug = true
if err := s.Execute("sudo password"); err != nil {
log.Fatal(err)
}
```## Runnning Tests
```bash
$ go test -v ./...
```Success of this test will be determined by the environment.
Now, test supported OS are- Debian
- CentOS (8~)
- Fedora
- Arch Linux
- OpenSUSE tumbleweed/leap
- Ubuntu
- Gentoo## Task
`task` represents shell command.
### `Package` task
install package.
| Property | type | description |
|:--------:|:----:|:-----------:|
| Name | string | target package name |```go
import "github.com/moba1/dotsetup/v3"// install `sample-package`
p := dotsetup.Package{
Name: "sample-package"
}
```### `Curl` task
This task represents `curl` command.
| Property | type | description |
|:--------:|:----:|:-----------:|
| Args | []string | `curl` command arguments |```go
import "github.com/moba1/dotsetup/v3"// execute `curl -o /tmp/sample.txt https://github.com`
c := dotsetup.Curl{
Args: []string{
"-o", "/tmp/sample.txt", "https://github.com"
}
}
```### `Directory` task
create directory.
| Property | type | description |
|:--------:|:----:|:-----------:|
| Path | string | directory path |
| Mode | string | directory mode |```go
import "github.com/moba1/dotsetup/v3"// create `/tmp/directory` directory with mode "rwxr-xr-x"
d := dotsetup.Directory{
Path: "/tmp/directory"
Mode: "755"
}
```### `Execute` task
execute shell command.
| Property | type | description |
|:--------:|:----:|:-----------:|
| RawCommands | []dotsetup.ExecuteCommand | shell commands |```go
import "github.com/moba1/dotsetup/v3"// execute `sudo -S ls -l`
e := dotsetup.Execute{
RawCommands: []dotsetup.ExecuteCommand{
RawCommand: dotsetup.RawCommand{"ls", "-l"},
DoRoot: true
},
}
```### `Link` task
create symbolic link.
| Property | type | description |
|:--------:|:----:|:-----------:|
| Source | string | source path |
| Destination | string | destination path |
| Force | set force mode |```go
import "github.com/moba1/dotsetup/v3"// put symbolic link from `/dev/null` to `/tmp/null`
l := dotsetup.Link{
Source: "/dev/null"
Destination: "/tmp/null"
Force: true
}
```## `Os` var
`Os` var is os name.If runtime is Linux, `Os` var is equal to `/etc/os-release`'s `ID` var.
In other runtime, equal to `runtime.GOOS`.