Skip to content

Commit

Permalink
Repositioned parameters in functions in gnu_coreutils module
Browse files Browse the repository at this point in the history
Moved short_args and long_args closer to path parameters as they are
used more often than batch and sudo parameters. Hence decreased use
of keyword arguments (e.g., "short_args="). Hence improved readability.
Affected functions: cp(), ln(), ls(), mv(), rm().
  • Loading branch information
Andrew15-5 committed Jan 21, 2022
1 parent cee76e8 commit c9a6eac
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 143 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ python3 -m pip install niceshell

```bash
cd /tmp/
version=1.3.1 # Choose desired version
version=2.0.0 # Choose desired version
wget -c "https://github.com/Andrew15-5/niceshell/releases/download/v${version}/niceshell-${version}-py3-none-any.whl"
python3 -m pip -U --user install niceshell-${version}-py3-none-any.whl
```
Expand Down
2 changes: 1 addition & 1 deletion niceshell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"quotes_wrapper", "rm", "shell", "Shell", "ShortArgsOption", "UID",
"USER"]
__author__ = "Andrew Voynov"
__version__ = "1.3.1"
__version__ = "2.0.0"

GID = Shell("id -g").output()[:-1]
GROUP = Shell("id -gn").output()[:-1]
Expand Down
46 changes: 23 additions & 23 deletions niceshell/gnu_coreutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ def cd(path: str = '',

def cp(source_path: Union[str, Iterable[str]],
destination_path: str,
batch=False,
sudo=False,
short_args: Union[str, Iterable[str]] = [],
long_args: Iterable[str] = [],
batch=False,
sudo=False,
test=False) -> Union[Shell, str]:
"""
Wrapper for cp command from GNU Core Utilities.
Expand All @@ -69,13 +69,13 @@ def cp(source_path: Union[str, Iterable[str]],
source_path (str | Iterable[str]): file(s) and/or directory(-ies) that
is/are need to be copied.
destination_path (str): destination directory for source files/dirs.
batch (bool): wraps source_path in double quotes if False. Default is
False.
sudo (bool): adds sudo at the begining of cp command. Default is False.
short_args (str | Iterable[str]): string or array of short arguments.
Prefix-dash is ignored. Default is [] (no short arguments).
long_args (Iterable[str]): array of long arguments. Prefix-dashes are
ignored. Default is [] (no long arguments).
batch (bool): wraps source_path in double quotes if False. Default is
False.
sudo (bool): adds sudo at the begining of cp command. Default is False.
test (bool): return command itself without its execution (for test
purposes). Default is False.
Expand Down Expand Up @@ -111,10 +111,10 @@ def cp(source_path: Union[str, Iterable[str]],

def ln(source_path: Union[str, Iterable[str]],
destination_path: str,
batch=False,
sudo=False,
short_args: Union[str, Iterable[str]] = [],
long_args: Iterable[str] = [],
batch=False,
sudo=False,
test=False) -> Union[Shell, str]:
"""
Wrapper for ln command from GNU Core Utilities.
Expand All @@ -126,13 +126,13 @@ def ln(source_path: Union[str, Iterable[str]],
source_path (str | Iterable[str]): file(s) and/or directory(-ies) of
which (sym)link(s) is/are need to be created.
destination_path (str): destination directory for source files/dirs.
batch (bool): wraps source_path in double quotes if False. Default is
False.
sudo (bool): adds sudo at the begining of ln command. Default is False.
short_args (str | Iterable[str]): string or array of short arguments.
Prefix-dash is ignored. Default is [] (no short arguments).
long_args (Iterable[str]): array of long arguments. Prefix-dashes are
ignored. Default is [] (no long arguments).
batch (bool): wraps source_path in double quotes if False. Default is
False.
sudo (bool): adds sudo at the begining of ln command. Default is False.
test (bool): return command itself without its execution (for test
purposes). Default is False.
Expand Down Expand Up @@ -167,10 +167,10 @@ def ln(source_path: Union[str, Iterable[str]],


def ls(path: Union[str, Iterable[str]] = '',
batch=False,
sudo=False,
short_args: Union[str, Iterable[str]] = [],
long_args: Iterable[str] = [],
batch=False,
sudo=False,
test=False) -> Union[Shell, str]:
"""
Wrapper for ls command from GNU Core Utilities.
Expand All @@ -180,12 +180,12 @@ def ls(path: Union[str, Iterable[str]] = '',
Parameters:
path (str | Iterable[str]): directory(-ies) of which content is need to
be gathered. Default is '' (aka present/current working directory).
batch (bool): wraps path in double quotes if False. Default is False.
sudo (bool): adds sudo at the begining of ls command. Default is False.
short_args (str | Iterable[str]): string or array of short arguments.
Prefix-dash is ignored. Default is [] (no short arguments).
long_args (Iterable[str]): array of long arguments. Prefix-dashes are
ignored. Default is [] (no long arguments).
batch (bool): wraps path in double quotes if False. Default is False.
sudo (bool): adds sudo at the begining of ls command. Default is False.
test (bool): return command itself without its execution (for test
purposes). Default is False.
Expand Down Expand Up @@ -217,10 +217,10 @@ def ls(path: Union[str, Iterable[str]] = '',

def mv(source_path: Union[str, Iterable[str]],
destination_path: str,
batch=False,
sudo=False,
short_args: Union[str, Iterable[str]] = [],
long_args: Iterable[str] = [],
batch=False,
sudo=False,
test=False) -> Union[Shell, str]:
"""
Wrapper for mv command from GNU Core Utilities.
Expand All @@ -232,13 +232,13 @@ def mv(source_path: Union[str, Iterable[str]],
source_path (str | Iterable[str]): file(s) and/or directory(-ies) that
is/are need to be moved/renamed.
destination_path (str): destination directory for source files/dirs.
batch (bool): wraps source_path in double quotes if False. Default is
False.
sudo (bool): adds sudo at the begining of mv command. Default is False.
short_args (str | Iterable[str]): string or array of short arguments.
Prefix-dash is ignored. Default is [] (no short arguments).
long_args (Iterable[str]): array of long arguments. Prefix-dashes are
ignored. Default is [] (no long arguments).
batch (bool): wraps source_path in double quotes if False. Default is
False.
sudo (bool): adds sudo at the begining of mv command. Default is False.
test (bool): return command itself without its execution (for test
purposes). Default is False.
Expand Down Expand Up @@ -297,10 +297,10 @@ def pwd(short_args: Union[str, Iterable[str]] = [],


def rm(path: Union[str, Iterable[str]],
batch=False,
sudo=False,
short_args: Union[str, Iterable[str]] = [],
long_args: Iterable[str] = [],
batch=False,
sudo=False,
test=False) -> Union[Shell, str]:
"""
Wrapper for rm command from GNU Core Utilities.
Expand All @@ -312,12 +312,12 @@ def rm(path: Union[str, Iterable[str]],
Parameters:
path (str | Iterable[str]): file(s) and/or directory(-ies) that is/are
need to be removed.
batch (bool): wraps path in double quotes if False. Default is False.
sudo (bool): adds sudo at the begining of rm command. Default is False.
short_args (str | Iterable[str]): string or array of short arguments.
Prefix-dash is ignored. Default is [] (no short arguments).
long_args (Iterable[str]): array of long arguments. Prefix-dashes are
ignored. Default is [] (no long arguments).
batch (bool): wraps path in double quotes if False. Default is False.
sudo (bool): adds sudo at the begining of rm command. Default is False.
test (bool): return command itself without its execution (for test
purposes). Default is False.
Expand Down
20 changes: 10 additions & 10 deletions niceshell/gnu_coreutils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,36 @@ def cd(path: str = '',

def cp(source_path: Union[str, Iterable[str]],
destination_path: str,
batch: bool = False,
sudo: bool = False,
short_args: Union[str, Iterable[str]] = [],
long_args: Iterable[str] = [],
batch: bool = False,
sudo: bool = False,
test: bool = False) -> Union[Shell, str]: ...


def ln(source_path: Union[str, Iterable[str]],
destination_path: str,
batch: bool = False,
sudo: bool = False,
short_args: Union[str, Iterable[str]] = [],
long_args: Iterable[str] = [],
batch: bool = False,
sudo: bool = False,
test: bool = False) -> Union[Shell, str]: ...


def ls(path: Union[str, Iterable[str]] = '',
batch: bool = False,
sudo: bool = False,
short_args: Union[str, Iterable[str]] = [],
long_args: Iterable[str] = [],
batch: bool = False,
sudo: bool = False,
test: bool = False) -> Union[Shell, str]: ...


def mv(source_path: Union[str, Iterable[str]],
destination_path: str,
batch: bool = False,
sudo: bool = False,
short_args: Union[str, Iterable[str]] = [],
long_args: Iterable[str] = [],
batch: bool = False,
sudo: bool = False,
test: bool = False) -> Union[Shell, str]: ...


Expand All @@ -48,8 +48,8 @@ def pwd(short_args: Union[str, Iterable[str]] = [],


def rm(path: Union[str, Iterable[str]],
batch: bool = False,
sudo: bool = False,
short_args: Union[str, Iterable[str]] = [],
long_args: Iterable[str] = [],
batch: bool = False,
sudo: bool = False,
test: bool = False) -> Union[Shell, str]: ...
Loading

0 comments on commit c9a6eac

Please sign in to comment.