Skip to content

Commit

Permalink
feat: rename project from barrier to edless
Browse files Browse the repository at this point in the history
  • Loading branch information
WIttyJudge committed Nov 27, 2024
1 parent 27b570f commit 8608ae6
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ before:
- go mod tidy

builds:
- main: ./cmd/barrier
- main: ./cmd/adless
env:
- CGO_ENABLED=0
ldflags:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NAME=barrier
NAME=adless

SRC_PATH=./cmd/$(NAME)
BUILD_PATH=./build/$(NAME)
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# barrier
# adless

Barrier is an easy-to-use CLI tool that blocks domains by using your system's hosts file.
Adless is an easy-to-use CLI tool that blocks domains by using your system's hosts file.
Its main advantage is that it operates without running any background processes.
Instead, it collects domains from different sources, combines them, and updates your hosts file.

Expand All @@ -11,21 +11,21 @@ Instead, it collects domains from different sources, combines them, and updates
Arch Linux (AUR):

```bash
yay -S barrier
yay -S adless-bin
```

## Manual Installation

Download a binary from the [releases page](https://github.com/WIttyJudge/barrier/releases) for Linux, macOS or Windows.
Download a binary from the [releases page](https://github.com/WIttyJudge/adless/releases) for Linux, macOS or Windows.

# Usage

```
NAME:
barrier - Local domains blocker writter in Go
adless - Local domains blocker writter in Go
USAGE:
barrier [global options] command [command options]
adless [global options] command [command options]
VERSION:
v1.0.0
Expand All @@ -49,18 +49,18 @@ GLOBAL OPTIONS:

# Configuration file

Barrier supports reading and writing configuration files.
The default configuration file is located at `$HOME/.config/barrier/config.yml`,
Adless supports reading and writing configuration files.
The default configuration file is located at `$HOME/.config/adless/config.yml`,
but it can be redefined using `--config` flag or the following environment variables:

- BARRIER_CONFIG_PATH - Specifies the full path to the configuration file.
- BARRIER_CONFIG_HOME - Specifies the folder where the `config.yml` file is located.
- XDG_CONFIG_HOME - Specifies the base directory for user-specific configuration files. Barrier will look for `barrier/config.yml` within this directory.
- ADLESS_CONFIG_PATH - Specifies the full path to the configuration file.
- ADLESS_CONFIG_HOME - Specifies the folder where the `config.yml` file is located.
- XDG_CONFIG_HOME - Specifies the base directory for user-specific configuration files. Adless will look for `adless/config.yml` within this directory.

To create a local configuration file, run:

```bash
barrier config init
adless config init
```

# TODO:
Expand Down
4 changes: 2 additions & 2 deletions cmd/barrier/main.go → cmd/adless/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"barrier/internal/action"
"adless/internal/action"
"fmt"
"os"
"sort"
Expand Down Expand Up @@ -36,7 +36,7 @@ func setupApp() *cli.App {
action := action.New()

app := cli.NewApp()
app.Name = "barrier"
app.Name = "adless"
app.Usage = "Local domains blocker writter in Go"
app.UseShortOptionHandling = true
app.Version = version
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module barrier
module adless

go 1.22.0

Expand Down
4 changes: 2 additions & 2 deletions internal/action/action.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package action

import (
"barrier/internal/action/exit"
"barrier/internal/config"
"adless/internal/action/exit"
"adless/internal/config"

"github.com/rs/zerolog"
"github.com/urfave/cli/v2"
Expand Down
4 changes: 2 additions & 2 deletions internal/action/config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package action

import (
"barrier/internal/action/exit"
"barrier/internal/config"
"adless/internal/action/exit"
"adless/internal/config"

"github.com/urfave/cli/v2"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/action/disable.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package action

import (
"barrier/internal/action/exit"
"barrier/internal/hostsfile"
"adless/internal/action/exit"
"adless/internal/hostsfile"

"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"
Expand Down
4 changes: 2 additions & 2 deletions internal/action/enable.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package action

import (
"barrier/internal/action/exit"
"barrier/internal/hostsfile"
"adless/internal/action/exit"
"adless/internal/hostsfile"

"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"
Expand Down
4 changes: 2 additions & 2 deletions internal/action/restore.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package action

import (
"barrier/internal/action/exit"
"barrier/internal/hostsfile"
"adless/internal/action/exit"
"adless/internal/hostsfile"

"github.com/rs/zerolog/log"

Expand Down
4 changes: 2 additions & 2 deletions internal/action/status.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package action

import (
"barrier/internal/action/exit"
"barrier/internal/hostsfile"
"adless/internal/action/exit"
"adless/internal/hostsfile"

"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"
Expand Down
4 changes: 2 additions & 2 deletions internal/action/update.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package action

import (
"barrier/internal/action/exit"
"barrier/internal/hostsfile"
"adless/internal/action/exit"
"adless/internal/hostsfile"

"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"
Expand Down
10 changes: 5 additions & 5 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func Init() error {
func Edit() error {
location := location()

c, err := editor.Cmd("barrier", location)
c, err := editor.Cmd("adless", location)
if err != nil {
return err
}
Expand All @@ -145,19 +145,19 @@ func Edit() error {

// location returns the location of the config file.
func location() string {
if bcp := os.Getenv("BARRIER_CONFIG_PATH"); bcp != "" {
if bcp := os.Getenv("ADLESS_CONFIG_PATH"); bcp != "" {
return bcp
}

if bch := os.Getenv("BARRIER_CONFIG_HOME"); bch != "" {
if bch := os.Getenv("ADLESS_CONFIG_HOME"); bch != "" {
return filepath.Join(bch, "config.yml")
}

if xdgConfig := os.Getenv("XDG_CONFIG_HOME"); xdgConfig != "" {
return filepath.Join(xdgConfig, "barrier", "config.yml")
return filepath.Join(xdgConfig, "adless", "config.yml")
}

return filepath.Join(homeDir(), ".config", "barrier", "config.yml")
return filepath.Join(homeDir(), ".config", "adless", "config.yml")
}

// read reads config file by location in file system.
Expand Down
44 changes: 22 additions & 22 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (
)

func TestLoad(t *testing.T) {
td, err := os.MkdirTemp("", "barrier-config")
td, err := os.MkdirTemp("", "adless-config")
defer os.RemoveAll(td)

require.NoError(t, err)

t.Run("return default config if there is no local", func(t *testing.T) {
os.Setenv("BARRIER_CONFIG_HOME", "test")
defer os.Unsetenv("BARRIER_CONFIG_HOME")
os.Setenv("ADLESS_CONFIG_HOME", "test")
defer os.Unsetenv("ADLESS_CONFIG_HOME")

config, err := Load()

Expand All @@ -35,8 +35,8 @@ func TestLoad(t *testing.T) {
_, err = testConfig.WriteString("invalid yml content")
require.NoError(t, err)

os.Setenv("BARRIER_CONFIG_PATH", testConfig.Name())
defer os.Unsetenv("BARRIER_CONFIG_PATH")
os.Setenv("ADLESS_CONFIG_PATH", testConfig.Name())
defer os.Unsetenv("ADLESS_CONFIG_PATH")

config, err := Load()

Expand All @@ -52,8 +52,8 @@ func TestLoad(t *testing.T) {
_, err = testConfig.WriteString("blocklists:\n")
require.NoError(t, err)

os.Setenv("BARRIER_CONFIG_PATH", testConfig.Name())
defer os.Unsetenv("BARRIER_CONFIG_PATH")
os.Setenv("ADLESS_CONFIG_PATH", testConfig.Name())
defer os.Unsetenv("ADLESS_CONFIG_PATH")

config, err := Load()

Expand All @@ -69,8 +69,8 @@ func TestLoad(t *testing.T) {
_, err = testConfig.WriteString("blocklists:\n- target: https://test.com")
require.NoError(t, err)

os.Setenv("BARRIER_CONFIG_PATH", testConfig.Name())
defer os.Unsetenv("BARRIER_CONFIG_PATH")
os.Setenv("ADLESS_CONFIG_PATH", testConfig.Name())
defer os.Unsetenv("ADLESS_CONFIG_PATH")

config, err := Load()

Expand All @@ -80,7 +80,7 @@ func TestLoad(t *testing.T) {
}

func TestLoadByUser(t *testing.T) {
td, err := os.MkdirTemp("", "barrier-config")
td, err := os.MkdirTemp("", "adless-config")
defer os.RemoveAll(td)

require.NoError(t, err)
Expand Down Expand Up @@ -121,20 +121,20 @@ func TestLoadByUser(t *testing.T) {
}

func TestLocation(t *testing.T) {
t.Run("BARRIER_CONFIG_PATH environment variable", func(t *testing.T) {
bcp := path.Join(homeDir(), ".config", "test_barrier", "config.yml")
t.Run("ADLESS_CONFIG_PATH environment variable", func(t *testing.T) {
bcp := path.Join(homeDir(), ".config", "test_adless", "config.yml")

os.Setenv("BARRIER_CONFIG_PATH", bcp)
defer os.Unsetenv("BARRIER_CONFIG_PATH")
os.Setenv("ADLESS_CONFIG_PATH", bcp)
defer os.Unsetenv("ADLESS_CONFIG_PATH")

assert.Equal(t, location(), bcp)
})

t.Run("BARRIER_CONFIG_HOME environment variable", func(t *testing.T) {
bch := path.Join(homeDir(), ".config", "test_barrier")
t.Run("ADLESS_CONFIG_HOME environment variable", func(t *testing.T) {
bch := path.Join(homeDir(), ".config", "test_adless")

os.Setenv("BARRIER_CONFIG_HOME", bch)
defer os.Unsetenv("BARRIER_CONFIG_HOME")
os.Setenv("ADLESS_CONFIG_HOME", bch)
defer os.Unsetenv("ADLESS_CONFIG_HOME")

expected := filepath.Join(bch, "config.yml")
assert.Equal(t, location(), expected)
Expand All @@ -146,18 +146,18 @@ func TestLocation(t *testing.T) {
os.Setenv("XDG_CONFIG_HOME", xdgConfig)
defer os.Unsetenv("XDG_CONFIG_HOME")

expected := filepath.Join(xdgConfig, "barrier", "config.yml")
expected := filepath.Join(xdgConfig, "adless", "config.yml")
assert.Equal(t, location(), expected)
})

t.Run("default location", func(t *testing.T) {
expected := filepath.Join(homeDir(), ".config", "barrier", "config.yml")
expected := filepath.Join(homeDir(), ".config", "adless", "config.yml")
assert.Equal(t, location(), expected)
})
}

func TestRead(t *testing.T) {
td, err := os.MkdirTemp("", "barrier-config")
td, err := os.MkdirTemp("", "adless-config")
defer os.RemoveAll(td)

require.NoError(t, err)
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestHomeDir(t *testing.T) {
os.Setenv("SUDO_USER", "root")
defer os.Unsetenv("SUDO_USER")

expected := "/root/.config/barrier/config.yml"
expected := "/root/.config/adless/config.yml"
assert.Equal(t, location(), expected)
})
}
Expand Down
8 changes: 4 additions & 4 deletions internal/hostsfile/file.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package hostsfile

import (
"barrier/pkg/fsutil"
"adless/pkg/fsutil"
"errors"
"fmt"
"os"
Expand All @@ -11,9 +11,9 @@ import (
)

const (
StartTag = "###### START barrier\n"
EndTag = "###### END barrier"
DescriptionComment = "# Generated by the barrier CLI tool. DO NOT EDIT!\n"
StartTag = "###### START adless\n"
EndTag = "###### END adless"
DescriptionComment = "# Generated by the adless CLI tool. DO NOT EDIT!\n"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions internal/hostsfile/processor.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package hostsfile

import (
"barrier/internal/config"
"barrier/internal/http"
"adless/internal/config"
"adless/internal/http"
"fmt"
"slices"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion pkg/fsutil/fsutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestCopyFile(t *testing.T) {
td, err := os.MkdirTemp("", "barrier-fsutil")
td, err := os.MkdirTemp("", "adless-fsutil")
require.NoError(t, err)
defer os.RemoveAll(td)

Expand Down

0 comments on commit 8608ae6

Please sign in to comment.