mirror of
https://github.com/go-shiori/shiori.git
synced 2025-01-16 21:09:44 +08:00
Cleaned up command imports and descriptions
This commit is contained in:
parent
3826d4b7ab
commit
77a7ffd740
12 changed files with 60 additions and 49 deletions
20
README.md
20
README.md
|
@ -39,17 +39,17 @@ Usage:
|
||||||
shiori [command]
|
shiori [command]
|
||||||
|
|
||||||
Available Commands:
|
Available Commands:
|
||||||
account Manage account for accessing web interface.
|
account Manage account for accessing web interface
|
||||||
add Bookmark the specified URL.
|
add Bookmark the specified URL
|
||||||
delete Delete the saved bookmarks.
|
delete Delete the saved bookmarks
|
||||||
export Export bookmarks into HTML file in Netscape Bookmark format.
|
export Export bookmarks into HTML file in Netscape Bookmark format
|
||||||
help Help about any command
|
help Help about any command
|
||||||
import Import bookmarks from HTML file in Netscape Bookmark format.
|
import Import bookmarks from HTML file in Netscape Bookmark format
|
||||||
open Open the saved bookmarks.
|
open Open the saved bookmarks
|
||||||
print Print the saved bookmarks.
|
print Print the saved bookmarks
|
||||||
search Search bookmarks by submitted keyword.
|
search Search bookmarks by submitted keyword
|
||||||
serve Serve web app for managing bookmarks.
|
serve Serve web app for managing bookmarks
|
||||||
update Update the saved bookmarks.
|
update Update the saved bookmarks
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help help for shiori
|
-h, --help help for shiori
|
||||||
|
|
|
@ -2,20 +2,21 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
"syscall"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
accountCmd = &cobra.Command{
|
accountCmd = &cobra.Command{
|
||||||
Use: "account",
|
Use: "account",
|
||||||
Short: "Manage account for accessing web interface.",
|
Short: "Manage account for accessing web interface",
|
||||||
}
|
}
|
||||||
|
|
||||||
addAccountCmd = &cobra.Command{
|
addAccountCmd = &cobra.Command{
|
||||||
Use: "add username",
|
Use: "add username",
|
||||||
Short: "Create new account.",
|
Short: "Create new account",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
username := args[0]
|
username := args[0]
|
||||||
|
@ -40,7 +41,7 @@ var (
|
||||||
|
|
||||||
printAccountCmd = &cobra.Command{
|
printAccountCmd = &cobra.Command{
|
||||||
Use: "print",
|
Use: "print",
|
||||||
Short: "Print the saved accounts.",
|
Short: "Print the saved accounts",
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
keyword, _ := cmd.Flags().GetString("search")
|
keyword, _ := cmd.Flags().GetString("search")
|
||||||
|
@ -54,7 +55,7 @@ var (
|
||||||
|
|
||||||
deleteAccountCmd = &cobra.Command{
|
deleteAccountCmd = &cobra.Command{
|
||||||
Use: "delete [usernames]",
|
Use: "delete [usernames]",
|
||||||
Short: "Delete the saved accounts.",
|
Short: "Delete the saved accounts",
|
||||||
Long: "Delete accounts. " +
|
Long: "Delete accounts. " +
|
||||||
"Accepts space-separated list of usernames. " +
|
"Accepts space-separated list of usernames. " +
|
||||||
"If no arguments, all records will be deleted.",
|
"If no arguments, all records will be deleted.",
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/RadhiFadlillah/go-readability"
|
|
||||||
"github.com/RadhiFadlillah/shiori/model"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/RadhiFadlillah/go-readability"
|
||||||
|
"github.com/RadhiFadlillah/shiori/model"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
addCmd = &cobra.Command{
|
addCmd = &cobra.Command{
|
||||||
Use: "add url",
|
Use: "add url",
|
||||||
Short: "Bookmark the specified URL.",
|
Short: "Bookmark the specified URL",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
// Read flag and arguments
|
// Read flag and arguments
|
||||||
|
|
|
@ -2,14 +2,15 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
deleteCmd = &cobra.Command{
|
deleteCmd = &cobra.Command{
|
||||||
Use: "delete [indices]",
|
Use: "delete [indices]",
|
||||||
Short: "Delete the saved bookmarks.",
|
Short: "Delete the saved bookmarks",
|
||||||
Long: "Delete bookmarks. " +
|
Long: "Delete bookmarks. " +
|
||||||
"When a record is deleted, the last record is moved to the removed index. " +
|
"When a record is deleted, the last record is moved to the removed index. " +
|
||||||
"Accepts space-separated list of indices (e.g. 5 6 23 4 110 45), hyphenated range (e.g. 100-200) or both (e.g. 1-3 7 9). " +
|
"Accepts space-separated list of indices (e.g. 5 6 23 4 110 45), hyphenated range (e.g. 100-200) or both (e.g. 1-3 7 9). " +
|
||||||
|
|
|
@ -2,18 +2,19 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/RadhiFadlillah/shiori/model"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/RadhiFadlillah/shiori/model"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
exportCmd = &cobra.Command{
|
exportCmd = &cobra.Command{
|
||||||
Use: "export target-file",
|
Use: "export target-file",
|
||||||
Short: "Export bookmarks into HTML file in Netscape Bookmark format.",
|
Short: "Export bookmarks into HTML file in Netscape Bookmark format",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
err := exportBookmarks(args[0])
|
err := exportBookmarks(args[0])
|
||||||
|
|
|
@ -2,19 +2,20 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/PuerkitoBio/goquery"
|
|
||||||
"github.com/RadhiFadlillah/shiori/model"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/PuerkitoBio/goquery"
|
||||||
|
"github.com/RadhiFadlillah/shiori/model"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
importCmd = &cobra.Command{
|
importCmd = &cobra.Command{
|
||||||
Use: "import source-file",
|
Use: "import source-file",
|
||||||
Short: "Import bookmarks from HTML file in Netscape Bookmark format.",
|
Short: "Import bookmarks from HTML file in Netscape Bookmark format",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
generateTag := cmd.Flags().Changed("generate-tag")
|
generateTag := cmd.Flags().Changed("generate-tag")
|
||||||
|
|
|
@ -2,15 +2,16 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
openCmd = &cobra.Command{
|
openCmd = &cobra.Command{
|
||||||
Use: "open [indices]",
|
Use: "open [indices]",
|
||||||
Short: "Open the saved bookmarks.",
|
Short: "Open the saved bookmarks",
|
||||||
Long: "Open bookmarks in browser. " +
|
Long: "Open bookmarks in browser. " +
|
||||||
"Accepts space-separated list of indices (e.g. 5 6 23 4 110 45), hyphenated range (e.g. 100-200) or both (e.g. 1-3 7 9). " +
|
"Accepts space-separated list of indices (e.g. 5 6 23 4 110 45), hyphenated range (e.g. 100-200) or both (e.g. 1-3 7 9). " +
|
||||||
"If no arguments, ALL bookmarks will be opened.",
|
"If no arguments, ALL bookmarks will be opened.",
|
||||||
|
|
|
@ -3,16 +3,17 @@ package cmd
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/RadhiFadlillah/shiori/model"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/RadhiFadlillah/shiori/model"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
printCmd = &cobra.Command{
|
printCmd = &cobra.Command{
|
||||||
Use: "print [indices]",
|
Use: "print [indices]",
|
||||||
Short: "Print the saved bookmarks.",
|
Short: "Print the saved bookmarks",
|
||||||
Long: "Show the saved bookmarks by its DB index. " +
|
Long: "Show the saved bookmarks by its DB index. " +
|
||||||
"Accepts space-separated list of indices (e.g. 5 6 23 4 110 45), hyphenated range (e.g. 100-200) or both (e.g. 1-3 7 9). " +
|
"Accepts space-separated list of indices (e.g. 5 6 23 4 110 45), hyphenated range (e.g. 100-200) or both (e.g. 1-3 7 9). " +
|
||||||
"If no arguments, all records with actual index from DB are shown.",
|
"If no arguments, all records with actual index from DB are shown.",
|
||||||
|
|
|
@ -2,9 +2,10 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/RadhiFadlillah/shiori/database"
|
"github.com/RadhiFadlillah/shiori/database"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -13,7 +14,7 @@ var (
|
||||||
|
|
||||||
rootCmd = &cobra.Command{
|
rootCmd = &cobra.Command{
|
||||||
Use: "shiori",
|
Use: "shiori",
|
||||||
Short: "Simple command-line bookmark manager built with Go.",
|
Short: "Simple command-line bookmark manager built with Go",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,15 @@ package cmd
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
searchCmd = &cobra.Command{
|
searchCmd = &cobra.Command{
|
||||||
Use: "search keyword",
|
Use: "search keyword",
|
||||||
Short: "Search bookmarks by submitted keyword.",
|
Short: "Search bookmarks by submitted keyword",
|
||||||
Long: "Search bookmarks by looking for matching keyword in bookmark's title and content. " +
|
Long: "Search bookmarks by looking for matching keyword in bookmark's title and content. " +
|
||||||
"If no keyword submitted, print all saved bookmarks. " +
|
"If no keyword submitted, print all saved bookmarks. " +
|
||||||
"Search results will be different depending on DBMS that used by shiori :\n" +
|
"Search results will be different depending on DBMS that used by shiori :\n" +
|
||||||
|
|
17
cmd/serve.go
17
cmd/serve.go
|
@ -5,6 +5,14 @@ import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html/template"
|
||||||
|
"io"
|
||||||
|
"mime"
|
||||||
|
"net/http"
|
||||||
|
fp "path/filepath"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/RadhiFadlillah/shiori/assets"
|
"github.com/RadhiFadlillah/shiori/assets"
|
||||||
"github.com/RadhiFadlillah/shiori/model"
|
"github.com/RadhiFadlillah/shiori/model"
|
||||||
"github.com/dgrijalva/jwt-go"
|
"github.com/dgrijalva/jwt-go"
|
||||||
|
@ -13,13 +21,6 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
"html/template"
|
|
||||||
"io"
|
|
||||||
"mime"
|
|
||||||
"net/http"
|
|
||||||
fp "path/filepath"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -27,7 +28,7 @@ var (
|
||||||
tplCache *template.Template
|
tplCache *template.Template
|
||||||
serveCmd = &cobra.Command{
|
serveCmd = &cobra.Command{
|
||||||
Use: "serve",
|
Use: "serve",
|
||||||
Short: "Serve web app for managing bookmarks.",
|
Short: "Serve web app for managing bookmarks",
|
||||||
Long: "Run a simple annd performant web server which serves the site for managing bookmarks." +
|
Long: "Run a simple annd performant web server which serves the site for managing bookmarks." +
|
||||||
"If --port flag is not used, it will use port 8080 by default.",
|
"If --port flag is not used, it will use port 8080 by default.",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
|
@ -2,20 +2,21 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/RadhiFadlillah/go-readability"
|
|
||||||
"github.com/RadhiFadlillah/shiori/model"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/RadhiFadlillah/go-readability"
|
||||||
|
"github.com/RadhiFadlillah/shiori/model"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
updateCmd = &cobra.Command{
|
updateCmd = &cobra.Command{
|
||||||
Use: "update [indices]",
|
Use: "update [indices]",
|
||||||
Short: "Update the saved bookmarks.",
|
Short: "Update the saved bookmarks",
|
||||||
Long: "Update fields of an existing bookmark. " +
|
Long: "Update fields of an existing bookmark. " +
|
||||||
"Accepts space-separated list of indices (e.g. 5 6 23 4 110 45), hyphenated range (e.g. 100-200) or both (e.g. 1-3 7 9). " +
|
"Accepts space-separated list of indices (e.g. 5 6 23 4 110 45), hyphenated range (e.g. 100-200) or both (e.g. 1-3 7 9). " +
|
||||||
"If no arguments, ALL bookmarks will be updated. Update works differently depending on the flags:\n" +
|
"If no arguments, ALL bookmarks will be updated. Update works differently depending on the flags:\n" +
|
||||||
|
|
Loading…
Reference in a new issue