Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v2.0.0 beta 1 #28

Merged
merged 5 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .bin/update_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ if [[ "$PREV_VERSION" != "" && $VERSION == $PREV_VERSION ]]; then
exit 1
fi

for i in README.md ; do
sed -e "s#Version-${PREV_VERSION}-information#Version-${VERSION//-/--}-information#g" -e "s#tag/v${PREV_VERSION}#tag/v${VERSION}#g" $i > a
mv a $i
done
echo "$PREV_VERSION -> $VERSION (${PREV_VERSION//-/--} -> ${VERSION//-/--})"

sed -e "s#Version-${PREV_VERSION//-/--}-information#Version-${VERSION//-/--}-information#g" -e "s#tag/v${PREV_VERSION}#tag/v${VERSION}#g" README.md > a; mv a README.md
sed -e "s#version = \".*\"#version = \"${VERSION}\"#g" docs/config.toml > a ; mv a docs/config.toml
sed "s/^version= /version = "${VERSION}"/g" Cargo.toml > a && mv a Cargo.toml

echo "Replace version from \"${PREV_VERSION}\" to \"${VERSION}\""
3 changes: 2 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ jobs:
extended: true

- name: Build Site
run:
run: |
(cd docs ; hugo)


- name: Create Distributions
run:
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/versionup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Version Up
on:
push:
branches:
- 'release/v[0-9]+.[0-9]+.[0-9]*'
- 'release/v[0-9]+.[0-9]+.[0-9]*.*'

jobs:
versionup:
Expand All @@ -16,18 +16,13 @@ jobs:

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ steps.vars.outputs.branch }}
fetch-depth: 0

- name: Initialize
shell: bash
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1

- name: Version up
id: updating_version
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

[![Rust Report Card](https://rust-reportcard.xuri.me/badge/github.com/tamada/sibling)](https://rust-reportcard.xuri.me/report/github.com/tamada/sibling)

[![License](https://img.shields.io/badge/License-WTFPL-green.svg)](https://github.com/tamada/sibling/blob/master/LICENSE)
[![Version](https://img.shields.io/badge/Version-2.0.0--beta--1-green.svg)](https://github.com/tamada/sibling/releases/tag/v2.0.0-beta-1)
[![License](https://img.shields.io/badge/License-WTFPL-information.svg)](https://github.com/tamada/sibling/blob/master/LICENSE)
[![Version](https://img.shields.io/badge/Version-2.0.0--beta--1-information.svg)](https://github.com/tamada/sibling/releases/tag/v2.0.0-beta-1)

get the next/previous sibling directory name.

Expand Down Expand Up @@ -88,7 +88,7 @@ The `--init` option accepts only `bash`.
Other shell scripts are not supported, yet.

```shell
$(sibling --init bash)
eval "$(sibling --init bash)"
```

### :muscle: Compiling yourself
Expand Down
66 changes: 66 additions & 0 deletions assets/completions/bash/sibling
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
_sibling() {
local i cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cmd=""
opts=""

for i in ${COMP_WORDS[@]}
do
case "${cmd},${i}" in
",$1")
cmd="sibling"
;;
*)
;;
esac
done

case "${cmd}" in
sibling)
opts="-a -l -p -P -s -i -t -h -V --csv --absolute --list --progress --parent --step --init --type --help --version [DIR]..."
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--step)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-s)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--init)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-i)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--type)
COMPREPLY=($(compgen -W "first last previous next random keep" -- "${cur}"))
return 0
;;
-t)
COMPREPLY=($(compgen -W "first last previous next random keep" -- "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
esac
}

if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
complete -F _sibling -o nosort -o bashdefault -o default sibling
else
complete -F _sibling -o bashdefault -o default sibling
fi
43 changes: 43 additions & 0 deletions assets/completions/elvish/sibling
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

use builtin;
use str;

set edit:completion:arg-completer[sibling] = {|@words|
fn spaces {|n|
builtin:repeat $n ' ' | str:join ''
}
fn cand {|text desc|
edit:complex-candidate $text &display=$text' '(spaces (- 14 (wcswidth $text)))$desc
}
var command = 'sibling'
for word $words[1..-1] {
if (str:has-prefix $word '-') {
break
}
set command = $command';'$word
}
var completions = [
&'sibling'= {
cand -s 'specify the number of times to execute sibling'
cand --step 'specify the number of times to execute sibling'
cand -i 'generate the initialize script for the shell'
cand --init 'generate the initialize script for the shell'
cand -t 'specify the nexter type'
cand --type 'specify the nexter type'
cand --csv 'print the result in the csv format'
cand -a 'print the directory name in the absolute path'
cand --absolute 'print the directory name in the absolute path'
cand -l 'list the sibling directories'
cand --list 'list the sibling directories'
cand -p 'print the progress of traversing directories'
cand --progress 'print the progress of traversing directories'
cand -P 'print parent directory, when no more sibling directories are found'
cand --parent 'print parent directory, when no more sibling directories are found'
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
}
]
$completions[$command]
}
10 changes: 10 additions & 0 deletions assets/completions/fish/sibling
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
complete -c sibling -s s -l step -d 'specify the number of times to execute sibling' -r
complete -c sibling -s i -l init -d 'generate the initialize script for the shell' -r
complete -c sibling -s t -l type -d 'specify the nexter type' -r -f -a "{first\t'',last\t'',previous\t'',next\t'',random\t'',keep\t''}"
complete -c sibling -l csv -d 'print the result in the csv format'
complete -c sibling -s a -l absolute -d 'print the directory name in the absolute path'
complete -c sibling -s l -l list -d 'list the sibling directories'
complete -c sibling -s p -l progress -d 'print the progress of traversing directories'
complete -c sibling -s P -l parent -d 'print parent directory, when no more sibling directories are found'
complete -c sibling -s h -l help -d 'Print help'
complete -c sibling -s V -l version -d 'Print version'
49 changes: 49 additions & 0 deletions assets/completions/powershell/sibling
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

using namespace System.Management.Automation
using namespace System.Management.Automation.Language

Register-ArgumentCompleter -Native -CommandName 'sibling' -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)

$commandElements = $commandAst.CommandElements
$command = @(
'sibling'
for ($i = 1; $i -lt $commandElements.Count; $i++) {
$element = $commandElements[$i]
if ($element -isnot [StringConstantExpressionAst] -or
$element.StringConstantType -ne [StringConstantType]::BareWord -or
$element.Value.StartsWith('-') -or
$element.Value -eq $wordToComplete) {
break
}
$element.Value
}) -join ';'

$completions = @(switch ($command) {
'sibling' {
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'specify the number of times to execute sibling')
[CompletionResult]::new('--step', 'step', [CompletionResultType]::ParameterName, 'specify the number of times to execute sibling')
[CompletionResult]::new('-i', 'i', [CompletionResultType]::ParameterName, 'generate the initialize script for the shell')
[CompletionResult]::new('--init', 'init', [CompletionResultType]::ParameterName, 'generate the initialize script for the shell')
[CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'specify the nexter type')
[CompletionResult]::new('--type', 'type', [CompletionResultType]::ParameterName, 'specify the nexter type')
[CompletionResult]::new('--csv', 'csv', [CompletionResultType]::ParameterName, 'print the result in the csv format')
[CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'print the directory name in the absolute path')
[CompletionResult]::new('--absolute', 'absolute', [CompletionResultType]::ParameterName, 'print the directory name in the absolute path')
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'list the sibling directories')
[CompletionResult]::new('--list', 'list', [CompletionResultType]::ParameterName, 'list the sibling directories')
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'print the progress of traversing directories')
[CompletionResult]::new('--progress', 'progress', [CompletionResultType]::ParameterName, 'print the progress of traversing directories')
[CompletionResult]::new('-P', 'P ', [CompletionResultType]::ParameterName, 'print parent directory, when no more sibling directories are found')
[CompletionResult]::new('--parent', 'parent', [CompletionResultType]::ParameterName, 'print parent directory, when no more sibling directories are found')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
break
}
})

$completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
Sort-Object -Property ListItemText
}
51 changes: 51 additions & 0 deletions assets/completions/zsh/_sibling
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#compdef sibling

autoload -U is-at-least

_sibling() {
typeset -A opt_args
typeset -a _arguments_options
local ret=1

if is-at-least 5.2; then
_arguments_options=(-s -S -C)
else
_arguments_options=(-s -C)
fi

local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" : \
'-s+[specify the number of times to execute sibling]:COUNT: ' \
'--step=[specify the number of times to execute sibling]:COUNT: ' \
'-i+[generate the initialize script for the shell]:SHELL: ' \
'--init=[generate the initialize script for the shell]:SHELL: ' \
'-t+[specify the nexter type]:TYPE:(first last previous next random keep)' \
'--type=[specify the nexter type]:TYPE:(first last previous next random keep)' \
'--csv[print the result in the csv format]' \
'-a[print the directory name in the absolute path]' \
'--absolute[print the directory name in the absolute path]' \
'-l[list the sibling directories]' \
'--list[list the sibling directories]' \
'-p[print the progress of traversing directories]' \
'--progress[print the progress of traversing directories]' \
'-P[print parent directory, when no more sibling directories are found]' \
'--parent[print parent directory, when no more sibling directories are found]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::dirs -- the target directory:_files' \
&& ret=0
}

(( $+functions[_sibling_commands] )) ||
_sibling_commands() {
local commands; commands=()
_describe -t commands 'sibling commands' commands "$@"
}

if [ "$funcstack[1]" = "_sibling" ]; then
_sibling "$@"
else
compdef _sibling sibling
fi
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pygmentsStyle = "pygments"
project_tagline = "get next/previous sibling directory name"
dateFormat = "2006-01-02"
katex = true
version = "1.3.0"
version = "2.0.0-beta-1"
footer = "[![GitHub](https://img.shields.io/badge/GitHub-tamada/sibling-blueviolet.svg?logo=github)](https://github.com/tamada/sibling) Made with [Hugo](https://gohugo.io/). Theme by [Cayman](https://github.com/zwbetz-gh/cayman-hugo-theme). Deployed to [GitHub Pages](https://pages.github.com/)."

[menu]
Expand Down
4 changes: 2 additions & 2 deletions docs/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ title: ":house: Home"

[![Rust Report Card](https://rust-reportcard.xuri.me/badge/github.com/tamada/sibling)](https://rust-reportcard.xuri.me/report/github.com/tamada/sibling)

[![License](https://img.shields.io/badge/License-WTFPL-green.svg)](https://github.com/tamada/sibling/blob/master/LICENSE)
[![Version](https://img.shields.io/badge/Version-{{ .Site.Params.version }}-green.svg)](https://github.com/tamada/sibling/releases/tag/v{{ .Site.Params.version }})
[![License](https://img.shields.io/badge/License-WTFPL-information.svg)](https://github.com/tamada/sibling/blob/master/LICENSE)
[![Version](https://img.shields.io/badge/Version-{{< version double_dash="true" >}}-information.svg)](https://github.com/tamada/sibling/releases/tag/v{{< version >}})

## :speaking_head: Description

Expand Down
5 changes: 5 additions & 0 deletions docs/layouts/shortcodes/version.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{- $version := $.Site.Params.version }}
{{- if eq (.Get "double_dash") "true" -}}
{{- $version = strings.Replace $version "-" "--" -}}
{{- end -}}
{{ $version }}
6 changes: 3 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ pub struct CliOpts {
#[arg(short, long, help = "specify the number of times to execute sibling", value_name = "COUNT", default_value_t = 1)]
pub step: i32,

#[arg(short, long, help = "generate the initialize script for the shell", value_name = "SHELL", hide = true)]
#[arg(short, long, help = "generate the initialize script for the shell", value_name = "SHELL", hide = true, default_missing_value = "bash")]
pub init: Option<String>,

#[arg(short = 't', long = "type", help = "specify the nexter type", value_enum, default_value_t = NexterType::Next, value_name = "TYPE", ignore_case = true)]
pub nexter: NexterType,

#[arg(index = 1, help = "the directory for listing the siblings", value_name = "DIR", default_value = ".")]
pub dir: PathBuf,
#[arg(index = 1, help = "the target directory", value_name = "DIR")]
pub dirs: Vec<PathBuf>,
}

#[derive(Debug, Parser)]
Expand Down
14 changes: 11 additions & 3 deletions src/dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Dirs {
if current_dir == PathBuf::from(".") {
match std::env::current_dir() {
Ok(dir) =>
build_dirs(current_dir.parent(), dir),
build_dirs(dir.clone().parent(), dir),
Err(e) => Err(SiblingError::Io(e)),
}
} else if current_dir.exists() {
Expand Down Expand Up @@ -92,10 +92,18 @@ mod tests {

#[test]
fn test_dirs_new() {
let dirs = Dirs::new(PathBuf::from("testdata/b"));
let dirs = Dirs::new(PathBuf::from("testdata/d"));
assert!(dirs.is_ok());
let dirs = dirs.unwrap();
assert_eq!(dirs.dirs.len(), 26);
assert_eq!(dirs.current, 1);
assert_eq!(dirs.current, 3);
}

#[test]
fn test_dir_dot() {
let dirs = Dirs::new(PathBuf::from("."));
assert!(dirs.is_ok());
let dirs = dirs.unwrap();
assert_eq!(dirs.current_path().file_name().map(|s| s.to_str()), Some("sibling".into()));
}
}
2 changes: 1 addition & 1 deletion src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rust_embed::Embed;
use crate::cli::{Result, SiblingError};

#[derive(Embed)]
#[folder = "assets"]
#[folder = "assets/init"]
struct Assets;

pub(crate) fn generate_init_script(shell_name: String) -> Result<String> {
Expand Down
Loading
Loading