fix: find config in .config dir

This commit is contained in:
2024-12-24 03:34:06 +02:00
parent 2eb75e01d2
commit 18c7933c0b
2 changed files with 6 additions and 229 deletions

View File

@@ -99,7 +99,7 @@ func FindConfigFile() string {
}
home, err := os.UserHomeDir()
file := ""
dirs := []string{wd, home}
dirs := []string{wd, filepath.Join(home, ".config"), home}
for _, dir := range dirs {
file = tryConfigDir(dir)
if file != "" {
@@ -120,12 +120,13 @@ func tryConfigDir(dir string) string {
}
func ParseCliConfig() *AppCliConfig {
args := os.Args[1:]
config := &AppCliConfig{}
file := FindConfigFile()
tVal := true
fVal := false
for len(os.Args) > 0 {
switch os.Args[0] {
for len(args) > 0 {
switch args[0] {
case "-d", "--debug":
config.Debug = &tVal
case "-D", "--no-debug":
@@ -139,10 +140,10 @@ func ParseCliConfig() *AppCliConfig {
os.Exit(0)
default:
if file == "" {
file = os.Args[0]
file = args[0]
}
}
os.Args = os.Args[1:]
args = args[1:]
}
if file == "" {
fmt.Println("No config file found")

View File

@@ -1,224 +0,0 @@
# debug: true
# check_updates: true
defaults:
type:
brew:
platforms:
only: ['macos']
install:
- name: nvim
type: rsync
opts:
source: ~/.dotfiles/.config/nvim/
destination: ~/.config/nvim/
flags: --delete --exclude .git --exclude .DS_Store
- name: lazygit
type: rsync
opts:
source: ~/.dotfiles/.config/lazygit.yml
destination: ~/Library/ApplicationSupport/lazygit/config.yml
- name: config
type: rsync
opts:
source: ~/.dotfiles/.config/
destination: ~/.config/
flags: --exclude lazygit.yml --exclude nvim --exclude .git --exclude .DS_Store
- name: treelike
type: brew
opts:
tap: chenasraf/tap
- name: lazygit
type: group
steps:
- name: lazygit
type: brew
opts:
tap: jesseduffield/lazygit
- name: lazygit
type: shell
platforms:
only: ['linux']
opts:
command: |
cd $(mktemp -d)
lazygit_version=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${lazygit_version}_Linux_x86_64.tar.gz"
tar xf lazygit.tar.gz lazygit
sudo install lazygit /usr/local/bin
- name: lazydocker
type: group
steps:
- name: lazydocker
type: brew
opts:
tap: jesseduffield/lazydocker
- name: lazydocker
type: shell
platforms:
only: ['linux']
opts:
command: |
cd $(mktemp -d)
lazydocker_version=$(curl -s "https://api.github.com/repos/jesseduffield/lazydocker/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
curl -Lo lazydocker.tar.gz "https://github.com/jesseduffield/lazydocker/releases/latest/download/lazydocker_${lazydocker_version}_Linux_x86_64.tar.gz"
tar xf lazydocker.tar.gz lazydocker
sudo install lazydocker /usr/local/bin
- name: fnm
type: shell
post_install: |
fnm install --lts
fnm use lts-latest
opts:
command: curl -fsSL https://fnm.vercel.app/install | bash
- name: pyenv
type: group
steps:
- name: pyenv
type: brew
- name: pyenv
type: shell
platforms:
only: ['linux']
opts:
command: 'curl https://pyenv.run | bash'
- name: pipx
type: group
post_install: sudo pipx ensurepath --global
steps:
- name: pipx
type: brew
- name: pipx
type: apt
platforms:
only: ['linux']
- name: jq
type: brew
- name: yq
type: shell
opts:
command: pipx install yq
- name: direnv
type: group
steps:
- name: direnv
type: brew
- name: direnv
type: shell
platforms:
only: ['linux']
opts:
command: export bin_path=/usr/local/bin curl -sfL https://direnv.net/install.sh | bash
- name: dotenvx
type: group
steps:
- name: dotenvx
type: brew
opts:
tap: dotenvx/brew
- name: dotenvx
type: shell
platforms:
only: ['linux']
opts:
command: curl -sfS https://dotenvx.sh | sh
- name: ollama
type: brew
post_install: brew services start ollama
- name: gi_gen
type: group
steps:
- name: gi_gen
type: brew
opts:
tap: chenasraf/tap
- name: gi_gen
type: shell
platforms:
only: ['linux']
opts:
command: |
gi_ver=$(get-gh-latest-tag "chenasraf/gi_gen")
mkdir -p "$DOTBIN_META"
arch=$(archmatch -mA "macos-arm" -mI "macos-intel" -l "linux-amd")
curl -L https://github.com/chenasraf/gi_gen/releases/download/$gi_ver/gi_gen-$gi_ver-$arch -o $DOTBIN/gi_gen
- name: treelike
type: group
steps:
- name: treelike
type: brew
opts:
tap: chenasraf/tap
- name: treelike
type: shell
platforms:
only: ['linux']
opts:
command: |
gi_ver=$(get-gh-latest-tag "chenasraf/treelike")
mkdir -p "$DOTBIN_META"
arch=$(archmatch -mA "macos-arm" -mI "macos-intel" -l "linux-amd")
curl -L https://github.com/chenasraf/treelike/releases/download/$treelike_ver/treelike-$arch.tar.gz -o $DOTBIN/treelike.tar.gz
- name: pnpm
type: group
check_installed: |
[[ \
$(which pnpm) && \
$(which tsc) && \
$(which tldr) && \
$(which simple-scaffold) && \
$(which firebase) && \
$(which prettier) && \
$(which http-server) && \
$(which licenseg) && \
$(which vscode-json-language-server) \
]]; exit $?
steps:
- name: pnpm
type: shell
opts:
command: npm i -g pnpm
- name: tsc
type: shell
opts:
command: pnpm i -g typescript
- name: tldr
type: shell
opts:
command: pnpm i -g tldr
- name: simple-scaffold
type: shell
opts:
command: pnpm i -g simple-scaffold
- name: firebase
type: shell
opts:
command: pnpm i -g firebase-tools
- name: prettier
type: shell
opts:
command: pnpm i -g prettier
- name: http-server
type: shell
opts:
command: pnpm i -g http-server
- name: licenseg
type: shell
opts:
command: pnpm i -g licenseg
- name: vscode-json-language-server
type: shell
opts:
command: pnpm i -g vscode-langservers-extracted
- name: home
type: shell
opts:
bin_name: tx
command: |
cd $DOTFILES/utils
pnpm i && pnpm build && pnpm ginst
- name: zplug
type: shell
check_installed: test -d ~/.zplug; exit $?
opts:
command: curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh