Skip to content

Commit

Permalink
Merge pull request #9 from nodew/update-readme
Browse files Browse the repository at this point in the history
Update the README for the CLI
  • Loading branch information
nodew authored Dec 26, 2023
2 parents 875c457 + ec11427 commit 2ca6456
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.CommandLine;
using System.IO;

namespace PwSafeClient.CLI.Commands;

Expand Down
3 changes: 2 additions & 1 deletion src/PwSafeClient.CLI/PwSafeClient.CLI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<AssemblyName>pwsafe</AssemblyName>
<Version>1.0.0-beta</Version>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
163 changes: 139 additions & 24 deletions src/PwSafeClient.CLI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,172 @@
## Configuration

```json
// ~/pwsafe.json
// ~/.pwsafe/config.json
{
"defaultDb": "<alias>", // The default database to operate if you don't specific the alias or the file path to your pwsafe database in the command line.
"databases": {
"default": "Default path to your PasswordSafe file"
}
"<alias>": "The Absolute file path to your PasswordSafe file",
...
},
"idleTime": 5, // Default to be 5 minutes, which means the interactive window will automatically close in 5 minutes if there's no operation.
"maxBackupCount": 5 // Default to keep 5 backup files.
}
```

## Commands

### Get password
```bash
Usage:
pwsafe [command] [options]

Options:
--version Show version information
-?, -h, --help Show help and usage information

Commands:
config Manage your pwsafe config file
choose <ALIAS> Choose a database to operate
listdb List all databases
showdb Show the detail of PasswordSafe database
createdb <FILE> Create an empty new PasswordSafe v3 database file
list List the items in database
add Add a new entry to the database
get <ID> Get the password of an entry
renew <ID> Renew the password of an entry
update <ID> Update the properties of an entry
rm <ID> Remove an entry or group from the database
unlock Unlock a database
```

```sh
$ pwsafe --title facebook
Enter your password: ******
Successfully copy password to clipboard
### Manage configuration via CLI

$ pwsafe --alias default --title facebook
#### 1. Init config

$ pwsafe --file /a/b/c/pwsafe.psafe3 --title facebook
```bash
$ pwsafe config init
```

### Show metadata of a PasswordSafe file
#### 2. Set alias for a pwsafe database file

```bash
$ pwsafe config set --alias <alias> --file <filepath>
# OR
$ pwsafe config set -a <alias> -f <filepath>
# Make the database as default
$ pwsafe config set -a <alias> -f <filepath> --default
```

```sh
$ pwsafe showdb
#### 3. Remove an alias

$ pwsafe showdb --alias default
```bash
$ pwsafe config rm <alias>
```

$ pwsafe showdb --file /a/b/c/pwsafe.psafe3
#### 4. Set the default database

```bash
$ pwsafe choose <alias>
```

### Create a new PasswordSafe file
#### 5. List all configured databases

```sh
$ pwsafe createdb pwsafe --path /a/b/c
```bash
$ pwsafe listdb
```

### List available items in a PasswordSafe file
### Manage database via CLI

```sh
#### 1. Create an empty database

```bash
$ pwsafe createdb <filepath> --alias <alias>
# To make the new database as default database
$ pwsafe createdb <filepath> --alias <alias> --default
# Force to create a new database if file exists, use it on your own risk!
$ pwsafe createdb <filepath> --alias <alias> --force
```

#### 2. Show metadata of an database

```bash
$ pwsafe showdb --alias <alias>
# OR
$ pwsafe showdb --file <filepath>
```

### Manage the entries in database in CLI

#### 1. List available entries

```bash
# List entries of the default database
$ pwsafe list
# List entries of the given alias
$ pwsafe list --alias <alias>
# List entries of the given filepath
$ pwsafe list --file <filepath>
# List entries in tree view
$ pwsafe list --mode tree
# Filter items by title
$ pwsafe list --filter <title>
```

$ pwsafe list --alias default
PS. the `alias` option and the `file` option are available for the following sections.

#### 2. Get password

```bash
$ pwsafe get <ID>
Enter your password: ******
Successfully copy password to clipboard
```

#### 3. Add a new entry

```bash
$ pwsafe --title <title> --username <username> --password <password> --group <group> --url <url> --email <email> --notes <notes>
# Read the password interactively
$ pwsafe --title <title> --username <username> --password
# Generate the password via named password policies
$ pwsafe --title <title> --username <username> --policy <policy>
```

PS. the sub-groups are separated by `.`, for example: `A/B/C` is represented as `A.B.C`

#### 4. Renew the password

```bash
$ pwsafe renew <ID>
# Renew with given password
$ pwsafe renew <ID> --password <password>
# Renew with given password interactively
$ pwsafe renew <ID> --password
# Renew the password via named password policies
$ pwsafe renew <ID> --policy <policy>
```

#### 5. Update the properties of an entry

```bash
$ pwsafe update <ID> --title <title> --username <username> --group <group> --url <url> --email <email> --notes <notes>
```

$ pwsafe list --file /a/b/c/pwsafe.psafe3
#### 6. Remove an entry or entire group

$ pwsafe list -group # show items in specific group
```bash
# Remove an entry
$ pwsafe rm <ID>
# Remove a group
$ pwsafe rm --group <group>
```

### [TODO] Create new password / Update password
### Interactive mode

It's boring to enter password for every operation, if you want to do a lot operations, you can unlock the database in interactively mode. The session will automatically exit if you don't take any actions.

```bash
# It will be unlock as read mode by default.
$ pwsafe unlock
# Unlock database in read-write mode
$ pwsafe unlock --read-only false
```

0 comments on commit 2ca6456

Please sign in to comment.