Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Donders-Institute/dr-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
hurngchunlee committed Jan 27, 2022
2 parents 50f7021 + d0ca170 commit b57d8dc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Donders Institute for Brain, Cognition and Behaviour

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 5 additions & 1 deletion build/rpm/centos7.spec
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ CLI tools for interacting various services managed by the TG.
mkdir -p %{gopath}
# copy entire directory into gopath, this duplicate the source code
GOPATH=%{gopath} make
%{gopath}/bin/repocli completion bash > %{gopath}/bash_completion

%install
mkdir -p %{buildroot}/%{_bindir}
mkdir -p %{buildroot}/%{_sbindir}
#mkdir -p %{buildroot}/%{_sysconfdir}/bash_completion.d
mkdir -p %{buildroot}/%{_sysconfdir}/bash_completion.d
## install files for client tools
install -m 755 %{gopath}/bin/repoadm %{buildroot}/%{_sbindir}/repoadm
install -m 755 %{gopath}/bin/repocli %{buildroot}/%{_bindir}/repocli
install -m 644 %{gopath}/bash_completion %{buildroot}/%{_sysconfdir}/bash_completion.d/repocli

%files
%{_sbindir}/repoadm
%{_bindir}/repocli
%{_sysconfdir}/bash_completion.d/repocli

%clean
chmod -R +w %{gopath}
Expand All @@ -48,3 +51,4 @@ rm -rf $RPM_BUILD_ROOT
%changelog
* Thu Jan 27 2022 Hong Lee <[email protected]> - 0.1
- first rpmbuild implementation
- include bash completion for repocli
33 changes: 9 additions & 24 deletions cmd/repocli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ Usage:
repocli [command]
Available Commands:
completion generate the autocompletion script for the specified shell
completion Generate the autocompletion script for the specified shell
cp copy file or directory in the repository
get download file or directory from the repository
help Help about any command
login login the repository with the data-access account
ls list file or directory in the repository
mkdir create new directory in the repository
mv move file or directory in the repository
Expand All @@ -35,42 +36,27 @@ Available Commands:
shell start an interactive shell
Flags:
-c, --config path path of the configuration YAML file. (default "/home/honlee/.repocli.yml")
-c, --config path path of the configuration YAML file. (default "/home/tg/honlee/.repocli.yml")
-h, --help help for repocli
-n, --nthreads number number of concurrent worker threads. (default 4)
-s, --silent set to slient mode (i.e. do not show progress)
-u, --url URL URL of the webdav server.
-v, --verbose verbose output
Use "repocli [command] --help" for more information about a command.
A CLI for managing data content of the Donders Repository collections.
```

The username/password of the data-access account should be provided in the configuration file (i.e. the `-c` flag) in YAML format. The default location of this configuration file is `${HOME}/.repocli.yml` on Linux/MacOSX and `C:\Users\<username>\.repocli.yml` on Windows. Hereafter is an example:

```yaml
repository:
username: "username"
password: "password"
```
__The configuration file__

When using the single-command mode (i.e. not the shell mode, see below), the base URL of the repository should also be provided via the `-u` option. It can also be provided via the `baseurl` key in the configuration file, e.g.
The credential (username and password) of the data-access account should be provided in a configuration file (specified by the `-c` option) in the YAML format. The default location of this configuration file is `${HOME}/.repocli.yml` on Linux/MacOSX and `C:\Users\<username>\.repocli.yml` on Windows. Since the program expects that the password stored in the configuration file is encrypted, it is better to use the following command to generate (or overwrite) the file:

```yaml
repository:
baseurl: "https://webdav.data.donders.ru.nl"
username: "username"
password: "password"
```bash
$ repocli login
```

If the `-u` option and the `baseurl` key are both specified, the value provided by the `-u` option takes precedence.

__⚠️ The configuration is in plain text and thus you should make the configuration file only accessible to yourself. ⚠️__ On Linux and MacOSX, one can run the following command in a terminal:
You will be asked to provide the WebDAV's baseURL, username and password. After providing those values, type `y` to save the credential to the configuration file. Once it is done successfully, you can reuse the configuration file in the future to connect to the same WebDAV endpoint.

```bash
$ chmod 600 $HOME/.repocli.yml
```
💡You can use the `login` subcommand with the `-c` option to create multiple configuration files, each for a different WebDAV endpoint.

__The shell mode__

Expand All @@ -86,7 +72,6 @@ The CLI's specific prompt `> repocli` will be displayed as the screenshot below,

In the shell mode, the following additional operations are enabled:

- login: login the repository
- cd: change the present working directory in the repository
- pwd: show the present working directory in the repository
- lcd: change the present working directory at local
Expand Down

0 comments on commit b57d8dc

Please sign in to comment.