wikiwiki 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.ja.md +93 -3
- data/README.md +93 -3
- data/exe/wikiwiki +8 -0
- data/lib/wikiwiki/api.rb +38 -6
- data/lib/wikiwiki/auth/token.rb +23 -0
- data/lib/wikiwiki/auth.rb +6 -0
- data/lib/wikiwiki/cli/commands/attachment/delete.rb +48 -0
- data/lib/wikiwiki/cli/commands/attachment/get.rb +45 -0
- data/lib/wikiwiki/cli/commands/attachment/list.rb +37 -0
- data/lib/wikiwiki/cli/commands/attachment/put.rb +60 -0
- data/lib/wikiwiki/cli/commands/attachment/show.rb +44 -0
- data/lib/wikiwiki/cli/commands/auth.rb +32 -0
- data/lib/wikiwiki/cli/commands/base.rb +64 -0
- data/lib/wikiwiki/cli/commands/page/get.rb +46 -0
- data/lib/wikiwiki/cli/commands/page/list.rb +36 -0
- data/lib/wikiwiki/cli/commands/page/put.rb +40 -0
- data/lib/wikiwiki/cli/commands/page/show.rb +44 -0
- data/lib/wikiwiki/cli/formatter/json.rb +18 -0
- data/lib/wikiwiki/cli.rb +51 -0
- data/lib/wikiwiki/rate_limiter.rb +4 -12
- data/lib/wikiwiki/sliding_window.rb +1 -3
- data/lib/wikiwiki/version.rb +1 -1
- data/lib/wikiwiki/wiki.rb +7 -2
- data/lib/wikiwiki.rb +1 -1
- data/sig/dry/cli.rbs +9 -0
- data/sig/wikiwiki/api.rbs +5 -3
- data/sig/wikiwiki/auth/token.rbs +9 -0
- data/sig/wikiwiki/auth.rbs +2 -0
- data/sig/wikiwiki/cli/commands/attachment.rbs +96 -0
- data/sig/wikiwiki/cli/commands/auth.rbs +9 -0
- data/sig/wikiwiki/cli/commands/base.rbs +27 -0
- data/sig/wikiwiki/cli/commands/page.rbs +67 -0
- data/sig/wikiwiki/cli/formatter/json.rbs +9 -0
- data/sig/wikiwiki/cli.rbs +11 -0
- data/sig/wikiwiki/wiki.rbs +3 -1
- metadata +59 -8
- data/LICENSE.txt +0 -21
- data/mise.toml +0 -6
- data/rbs_collection.yaml +0 -12
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Wikiwiki
|
|
4
|
+
class CLI
|
|
5
|
+
# CLI command implementations
|
|
6
|
+
#
|
|
7
|
+
# This module serves as a namespace for all CLI commands.
|
|
8
|
+
# Commands are organized into submodules (Page, Attachment) for better organization.
|
|
9
|
+
module Commands
|
|
10
|
+
# Base command class with global options
|
|
11
|
+
class Base < Dry::CLI::Command
|
|
12
|
+
option :wiki_id, aliases: ["-w"], desc: "Wiki ID (or set WIKIWIKI_WIKI_ID)"
|
|
13
|
+
option :token, desc: "JWT token for authentication (or set WIKIWIKI_TOKEN)"
|
|
14
|
+
option :api_key_id, desc: "API Key ID for authentication (or set WIKIWIKI_API_KEY_ID)"
|
|
15
|
+
option :secret, desc: "API Key Secret for authentication (or set WIKIWIKI_SECRET)"
|
|
16
|
+
option :password, desc: "Password for authentication (or set WIKIWIKI_PASSWORD)"
|
|
17
|
+
option :verbose, aliases: ["-v"], type: :boolean, default: false, desc: "Verbose output"
|
|
18
|
+
option :debug, type: :boolean, default: false, desc: "Debug mode"
|
|
19
|
+
|
|
20
|
+
private def create_wiki(wiki_id: nil, token: nil, api_key_id: nil, secret: nil, password: nil, debug: false, out: $stdout, err: $stderr, **)
|
|
21
|
+
# Fallback to environment variables if options are not provided
|
|
22
|
+
wiki_id ||= ENV.fetch("WIKIWIKI_WIKI_ID", nil)
|
|
23
|
+
token ||= ENV.fetch("WIKIWIKI_TOKEN", nil)
|
|
24
|
+
api_key_id ||= ENV.fetch("WIKIWIKI_API_KEY_ID", nil)
|
|
25
|
+
secret ||= ENV.fetch("WIKIWIKI_SECRET", nil)
|
|
26
|
+
password ||= ENV.fetch("WIKIWIKI_PASSWORD", nil)
|
|
27
|
+
|
|
28
|
+
raise ArgumentError, "Wiki ID must be provided via --wiki-id or WIKIWIKI_WIKI_ID" unless wiki_id
|
|
29
|
+
|
|
30
|
+
auth = if token
|
|
31
|
+
Wikiwiki::Auth.token(token:)
|
|
32
|
+
elsif api_key_id && secret
|
|
33
|
+
Wikiwiki::Auth.api_key(api_key_id:, secret:)
|
|
34
|
+
elsif password
|
|
35
|
+
Wikiwiki::Auth.password(password:)
|
|
36
|
+
else
|
|
37
|
+
raise ArgumentError, "Either --token, API key (--api-key-id and --secret), or --password must be provided (via options or environment variables)"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
logger = create_logger(debug:, out:, err:)
|
|
41
|
+
Wiki.new(wiki_id:, auth:, logger:)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private def create_logger(debug:, out: $stdout, err: $stderr)
|
|
45
|
+
if debug
|
|
46
|
+
Logger.new(err, level: Logger::DEBUG)
|
|
47
|
+
elsif out.tty?
|
|
48
|
+
Logger.new(err, level: Logger::WARN)
|
|
49
|
+
else
|
|
50
|
+
Logger.new(IO::NULL)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
private def verbose?(verbose:, json: false, **) = verbose && !json
|
|
55
|
+
|
|
56
|
+
private def say(message, verbose:, out: $stdout, **)
|
|
57
|
+
return unless verbose?(verbose:)
|
|
58
|
+
|
|
59
|
+
out.puts message
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Wikiwiki
|
|
4
|
+
class CLI
|
|
5
|
+
module Commands
|
|
6
|
+
module Page
|
|
7
|
+
# Get page content
|
|
8
|
+
class Get < Base
|
|
9
|
+
desc "Get page content"
|
|
10
|
+
|
|
11
|
+
argument :page_name, required: true, desc: "Page name"
|
|
12
|
+
argument :output_file, required: false, desc: "Output file (stdout if omitted)"
|
|
13
|
+
option :force, aliases: ["-f"], type: :boolean, default: false, desc: "Overwrite existing file"
|
|
14
|
+
|
|
15
|
+
# Execute the get command
|
|
16
|
+
#
|
|
17
|
+
# @param page_name [String] name of the page to get
|
|
18
|
+
# @param output_file [String, nil] optional output file path
|
|
19
|
+
# @param force [Boolean] whether to overwrite existing file
|
|
20
|
+
# @param out [IO] output stream
|
|
21
|
+
# @param err [IO] error stream
|
|
22
|
+
# @return [void]
|
|
23
|
+
def call(page_name:, output_file: nil, force: false, out: $stdout, err: $stderr, **)
|
|
24
|
+
wiki = create_wiki(out:, err:, **)
|
|
25
|
+
|
|
26
|
+
# Check if output file exists when not forcing
|
|
27
|
+
if output_file && File.exist?(output_file) && !force
|
|
28
|
+
raise ArgumentError, "File '#{output_file}' already exists. Use --force to overwrite."
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
page = wiki.page(page_name:)
|
|
32
|
+
|
|
33
|
+
if output_file
|
|
34
|
+
File.write(output_file, page.source)
|
|
35
|
+
say("Page '#{page_name}' (#{page.source.bytesize} bytes) saved to #{output_file}", out:, **)
|
|
36
|
+
else
|
|
37
|
+
out.puts page.source
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
register "page get", Page::Get
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Wikiwiki
|
|
4
|
+
class CLI
|
|
5
|
+
# CLI command implementations
|
|
6
|
+
module Commands
|
|
7
|
+
# Page-related commands
|
|
8
|
+
module Page
|
|
9
|
+
# List all pages in the wiki
|
|
10
|
+
class List < Base
|
|
11
|
+
desc "List all pages"
|
|
12
|
+
|
|
13
|
+
option :json, aliases: ["-j"], type: :boolean, default: false, desc: "Output as JSON"
|
|
14
|
+
|
|
15
|
+
# Execute the list command
|
|
16
|
+
#
|
|
17
|
+
# @param options [Hash] command options including wiki_id, auth, json, verbose, out, err
|
|
18
|
+
# @return [void]
|
|
19
|
+
def call(out: $stdout, err: $stderr, **options)
|
|
20
|
+
wiki = create_wiki(out:, err:, **options)
|
|
21
|
+
page_names = wiki.page_names
|
|
22
|
+
|
|
23
|
+
if options[:json]
|
|
24
|
+
out.puts Formatter::JSON.new.format(page_names)
|
|
25
|
+
else
|
|
26
|
+
page_names.each {|name| out.puts name }
|
|
27
|
+
say("#{page_names.size} pages found", out:, **options)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
register "page list", Page::List
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Wikiwiki
|
|
4
|
+
class CLI
|
|
5
|
+
module Commands
|
|
6
|
+
module Page
|
|
7
|
+
# Upload/update page content (creates if not exists)
|
|
8
|
+
class Put < Base
|
|
9
|
+
desc "Upload/update page content (creates if not exists)"
|
|
10
|
+
|
|
11
|
+
argument :page_name, required: true, desc: "Page name"
|
|
12
|
+
argument :input_file, required: false, desc: "Input file (stdin if omitted)"
|
|
13
|
+
|
|
14
|
+
# Execute the put command
|
|
15
|
+
#
|
|
16
|
+
# @param page_name [String] name of the page to update
|
|
17
|
+
# @param input_file [String, nil] optional input file path (uses stdin if nil)
|
|
18
|
+
# @param out [IO] output stream
|
|
19
|
+
# @param err [IO] error stream
|
|
20
|
+
# @return [void]
|
|
21
|
+
def call(page_name:, input_file: nil, out: $stdout, err: $stderr, **)
|
|
22
|
+
wiki = create_wiki(out:, err:, **)
|
|
23
|
+
|
|
24
|
+
source = if input_file
|
|
25
|
+
File.read(input_file)
|
|
26
|
+
else
|
|
27
|
+
$stdin.read
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
wiki.update_page(page_name:, source:)
|
|
31
|
+
|
|
32
|
+
say("Page '#{page_name}' updated successfully", out:, **)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
register "page put", Page::Put
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Wikiwiki
|
|
4
|
+
class CLI
|
|
5
|
+
module Commands
|
|
6
|
+
module Page
|
|
7
|
+
# Show page metadata
|
|
8
|
+
class Show < Base
|
|
9
|
+
desc "Show page metadata"
|
|
10
|
+
|
|
11
|
+
argument :page_name, required: true, desc: "Page name"
|
|
12
|
+
option :json, aliases: ["-j"], type: :boolean, default: false, desc: "Output as JSON"
|
|
13
|
+
|
|
14
|
+
# Execute the show command
|
|
15
|
+
#
|
|
16
|
+
# @param page_name [String] name of the page to show
|
|
17
|
+
# @param options [Hash] command options including wiki_id, auth, json, verbose, out, err
|
|
18
|
+
# @return [void]
|
|
19
|
+
def call(page_name:, out: $stdout, err: $stderr, **options)
|
|
20
|
+
wiki = create_wiki(out:, err:, **options)
|
|
21
|
+
page = wiki.page(page_name:)
|
|
22
|
+
|
|
23
|
+
metadata = {
|
|
24
|
+
"name" => page.name,
|
|
25
|
+
"timestamp" => page.timestamp.iso8601,
|
|
26
|
+
"source_size" => page.source.bytesize
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if options[:json]
|
|
30
|
+
out.puts Formatter::JSON.new.format(metadata)
|
|
31
|
+
else
|
|
32
|
+
out.puts "Name: #{metadata["name"]}"
|
|
33
|
+
out.puts "Timestamp: #{metadata["timestamp"]}"
|
|
34
|
+
out.puts "Source size: #{metadata["source_size"]} bytes"
|
|
35
|
+
say("Page metadata retrieved", out:, **options)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
register "page show", Page::Show
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module Wikiwiki
|
|
6
|
+
class CLI
|
|
7
|
+
module Formatter
|
|
8
|
+
# JSON output formatter for CLI commands
|
|
9
|
+
class JSON
|
|
10
|
+
# Format data as pretty-printed JSON
|
|
11
|
+
#
|
|
12
|
+
# @param data [Object] data to format (Hash, Array, etc.)
|
|
13
|
+
# @return [String] formatted JSON string
|
|
14
|
+
def format(data) = ::JSON.pretty_generate(data)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
data/lib/wikiwiki/cli.rb
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "dry/cli"
|
|
4
|
+
require "logger"
|
|
5
|
+
|
|
6
|
+
module Wikiwiki
|
|
7
|
+
# Command-line interface for Wikiwiki
|
|
8
|
+
#
|
|
9
|
+
# Provides commands for managing wiki pages and attachments through the terminal.
|
|
10
|
+
# Supports authentication via API key or password, with configurable logging and output modes.
|
|
11
|
+
class CLI
|
|
12
|
+
# Run the CLI with given arguments
|
|
13
|
+
#
|
|
14
|
+
# @param argv [Array<String>] command-line arguments
|
|
15
|
+
# @param out [IO] standard output (defaults to $stdout)
|
|
16
|
+
# @param err [IO] error output (defaults to $stderr)
|
|
17
|
+
# @return [Integer] exit code (0 for success, 1 for error)
|
|
18
|
+
def initialize(out: $stdout, err: $stderr)
|
|
19
|
+
@out = out
|
|
20
|
+
@err = err
|
|
21
|
+
@dry_cli = Dry::CLI.new(Commands)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Run the CLI with given arguments
|
|
25
|
+
#
|
|
26
|
+
# @param argv [Array<String>] command-line arguments
|
|
27
|
+
# @return [Integer] exit code (0 for success, 1 for error)
|
|
28
|
+
def run(argv)
|
|
29
|
+
@debug = argv.include?("--debug")
|
|
30
|
+
@dry_cli.call(arguments: argv, out: @out, err: @err)
|
|
31
|
+
0
|
|
32
|
+
rescue => e
|
|
33
|
+
handle_error(e)
|
|
34
|
+
1
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
attr_reader :out
|
|
38
|
+
attr_reader :err
|
|
39
|
+
|
|
40
|
+
# Handle and display errors
|
|
41
|
+
#
|
|
42
|
+
# @param error [Exception] the error to handle
|
|
43
|
+
# @return [void]
|
|
44
|
+
private def handle_error(error) = err.puts(@debug ? error.full_message : error.message)
|
|
45
|
+
|
|
46
|
+
# Command registry
|
|
47
|
+
module Commands
|
|
48
|
+
extend Dry::CLI::Registry
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -84,9 +84,7 @@ module Wikiwiki
|
|
|
84
84
|
#
|
|
85
85
|
# @return [void]
|
|
86
86
|
# @raise [RateLimitError] if rate limit is exceeded (with raise strategy)
|
|
87
|
-
def acquire!
|
|
88
|
-
@strategy.acquire!(self)
|
|
89
|
-
end
|
|
87
|
+
def acquire! = @strategy.acquire!(self)
|
|
90
88
|
|
|
91
89
|
# Get time in seconds until next request can be made
|
|
92
90
|
#
|
|
@@ -100,23 +98,17 @@ module Wikiwiki
|
|
|
100
98
|
# Check if a request can be made without exceeding any limits
|
|
101
99
|
#
|
|
102
100
|
# @return [Boolean] true if request is allowed
|
|
103
|
-
def can_request?
|
|
104
|
-
@windows.all?(&:can_request?)
|
|
105
|
-
end
|
|
101
|
+
def can_request? = @windows.all?(&:can_request?)
|
|
106
102
|
|
|
107
103
|
# Record a new request across all window limiters
|
|
108
104
|
#
|
|
109
105
|
# @return [void]
|
|
110
|
-
def record!
|
|
111
|
-
@windows.each(&:record!)
|
|
112
|
-
end
|
|
106
|
+
def record! = @windows.each(&:record!)
|
|
113
107
|
|
|
114
108
|
# Get maximum wait time across all window limiters
|
|
115
109
|
#
|
|
116
110
|
# @return [Float, nil] seconds to wait
|
|
117
|
-
def wait_time
|
|
118
|
-
@windows.map(&:wait_time).max
|
|
119
|
-
end
|
|
111
|
+
def wait_time = @windows.map(&:wait_time).max
|
|
120
112
|
|
|
121
113
|
attr_reader :mutex
|
|
122
114
|
end
|
data/lib/wikiwiki/version.rb
CHANGED
data/lib/wikiwiki/wiki.rb
CHANGED
|
@@ -17,8 +17,6 @@ module Wikiwiki
|
|
|
17
17
|
class Wiki
|
|
18
18
|
attr_reader :logger
|
|
19
19
|
|
|
20
|
-
private attr_reader :api, :wiki_id
|
|
21
|
-
|
|
22
20
|
# Initializes a new Wiki instance
|
|
23
21
|
#
|
|
24
22
|
# @param wiki_id [String] the wiki ID
|
|
@@ -34,6 +32,13 @@ module Wikiwiki
|
|
|
34
32
|
@api = API.new(wiki_id:, auth:, logger:, rate_limiter:)
|
|
35
33
|
end
|
|
36
34
|
|
|
35
|
+
# Returns the authentication token
|
|
36
|
+
#
|
|
37
|
+
# @return [String] JWT authentication token
|
|
38
|
+
def token = api.token
|
|
39
|
+
|
|
40
|
+
private attr_reader :api, :wiki_id
|
|
41
|
+
|
|
37
42
|
# Returns the wiki URL
|
|
38
43
|
#
|
|
39
44
|
# @return [URI::HTTPS] the frozen wiki URL
|
data/lib/wikiwiki.rb
CHANGED
data/sig/dry/cli.rbs
ADDED
data/sig/wikiwiki/api.rbs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Wikiwiki
|
|
2
2
|
class API
|
|
3
3
|
attr_reader logger: Logger
|
|
4
|
+
attr_reader token: String
|
|
4
5
|
|
|
5
|
-
def initialize: (wiki_id: String, auth: Auth::Password | Auth::ApiKey, logger: Logger, ?rate_limiter: RateLimiter) -> void
|
|
6
|
+
def initialize: (wiki_id: String, auth: Auth::Password | Auth::ApiKey | Auth::Token, logger: Logger, ?rate_limiter: RateLimiter) -> void
|
|
6
7
|
|
|
7
8
|
def get_pages: () -> Hash[String, Array[Hash[String, String]]]
|
|
8
9
|
|
|
@@ -20,7 +21,9 @@ module Wikiwiki
|
|
|
20
21
|
|
|
21
22
|
private
|
|
22
23
|
|
|
23
|
-
def authenticate: (Auth::Password | Auth::ApiKey auth) -> String
|
|
24
|
+
def authenticate: (Auth::Password | Auth::ApiKey | Auth::Token auth) -> String
|
|
25
|
+
|
|
26
|
+
def validate_token_expiry: (String token) -> void
|
|
24
27
|
|
|
25
28
|
def parse_json_response: (Net::HTTPResponse response) -> Hash[String, untyped]
|
|
26
29
|
|
|
@@ -31,6 +34,5 @@ module Wikiwiki
|
|
|
31
34
|
def log_response: (Net::HTTPResponse response) -> void
|
|
32
35
|
|
|
33
36
|
attr_reader wiki_id: String
|
|
34
|
-
attr_reader token: String
|
|
35
37
|
end
|
|
36
38
|
end
|
data/sig/wikiwiki/auth.rbs
CHANGED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
module Wikiwiki
|
|
2
|
+
class CLI
|
|
3
|
+
module Commands
|
|
4
|
+
module Attachment
|
|
5
|
+
class List < Base
|
|
6
|
+
def call: (
|
|
7
|
+
page_name: String,
|
|
8
|
+
?out: IO,
|
|
9
|
+
?err: IO,
|
|
10
|
+
?wiki_id: String?,
|
|
11
|
+
?api_key_id: String?,
|
|
12
|
+
?secret: String?,
|
|
13
|
+
?password: String?,
|
|
14
|
+
?json: bool,
|
|
15
|
+
?verbose: bool,
|
|
16
|
+
?debug: bool
|
|
17
|
+
) -> void
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class Show < Base
|
|
21
|
+
def call: (
|
|
22
|
+
page_name: String,
|
|
23
|
+
file_name: String,
|
|
24
|
+
?out: IO,
|
|
25
|
+
?err: IO,
|
|
26
|
+
?wiki_id: String?,
|
|
27
|
+
?api_key_id: String?,
|
|
28
|
+
?secret: String?,
|
|
29
|
+
?password: String?,
|
|
30
|
+
?json: bool,
|
|
31
|
+
?verbose: bool,
|
|
32
|
+
?debug: bool
|
|
33
|
+
) -> void
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class Get < Base
|
|
37
|
+
def call: (
|
|
38
|
+
page_name: String,
|
|
39
|
+
file_name: String,
|
|
40
|
+
?directory: String?,
|
|
41
|
+
?force: bool,
|
|
42
|
+
?out: IO,
|
|
43
|
+
?err: IO,
|
|
44
|
+
?wiki_id: String?,
|
|
45
|
+
?api_key_id: String?,
|
|
46
|
+
?secret: String?,
|
|
47
|
+
?password: String?,
|
|
48
|
+
?verbose: bool,
|
|
49
|
+
?debug: bool
|
|
50
|
+
) -> void
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
class Put < Base
|
|
54
|
+
def call: (
|
|
55
|
+
page_name: String,
|
|
56
|
+
file_path: String,
|
|
57
|
+
?name: String?,
|
|
58
|
+
?force: bool,
|
|
59
|
+
?out: IO,
|
|
60
|
+
?err: IO,
|
|
61
|
+
?wiki_id: String?,
|
|
62
|
+
?api_key_id: String?,
|
|
63
|
+
?secret: String?,
|
|
64
|
+
?password: String?,
|
|
65
|
+
?verbose: bool,
|
|
66
|
+
?debug: bool
|
|
67
|
+
) -> void
|
|
68
|
+
|
|
69
|
+
private
|
|
70
|
+
|
|
71
|
+
def attachment_exists?: (Wiki wiki, page_name: String, attachment_name: String) -> bool
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
class Delete < Base
|
|
75
|
+
def call: (
|
|
76
|
+
page_name: String,
|
|
77
|
+
file_name: String,
|
|
78
|
+
?out: IO,
|
|
79
|
+
?err: IO,
|
|
80
|
+
?wiki_id: String?,
|
|
81
|
+
?api_key_id: String?,
|
|
82
|
+
?secret: String?,
|
|
83
|
+
?password: String?,
|
|
84
|
+
?verbose: bool,
|
|
85
|
+
?debug: bool
|
|
86
|
+
) -> void
|
|
87
|
+
|
|
88
|
+
private
|
|
89
|
+
|
|
90
|
+
def page_exists?: (Wiki wiki, page_name: String) -> bool
|
|
91
|
+
def attachment_exists?: (Wiki wiki, page_name: String, attachment_name: String) -> bool
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Wikiwiki
|
|
2
|
+
class CLI
|
|
3
|
+
module Commands
|
|
4
|
+
class Base < Dry::CLI::Command
|
|
5
|
+
private
|
|
6
|
+
|
|
7
|
+
def create_wiki: (
|
|
8
|
+
?wiki_id: String?,
|
|
9
|
+
?token: String?,
|
|
10
|
+
?api_key_id: String?,
|
|
11
|
+
?secret: String?,
|
|
12
|
+
?password: String?,
|
|
13
|
+
?debug: bool,
|
|
14
|
+
?out: IO,
|
|
15
|
+
?err: IO,
|
|
16
|
+
**untyped
|
|
17
|
+
) -> Wiki
|
|
18
|
+
|
|
19
|
+
def create_logger: (debug: bool, ?out: IO, ?err: IO) -> Logger
|
|
20
|
+
|
|
21
|
+
def verbose?: (verbose: bool, ?json: bool, **untyped) -> bool
|
|
22
|
+
|
|
23
|
+
def say: (String message, verbose: bool, ?out: IO, **untyped) -> void
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
module Wikiwiki
|
|
2
|
+
class CLI
|
|
3
|
+
module Commands
|
|
4
|
+
module Page
|
|
5
|
+
class List < Base
|
|
6
|
+
def call: (
|
|
7
|
+
?out: IO,
|
|
8
|
+
?err: IO,
|
|
9
|
+
?wiki_id: String?,
|
|
10
|
+
?api_key_id: String?,
|
|
11
|
+
?secret: String?,
|
|
12
|
+
?password: String?,
|
|
13
|
+
?json: bool,
|
|
14
|
+
?verbose: bool,
|
|
15
|
+
?debug: bool
|
|
16
|
+
) -> void
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class Show < Base
|
|
20
|
+
def call: (
|
|
21
|
+
page_name: String,
|
|
22
|
+
?out: IO,
|
|
23
|
+
?err: IO,
|
|
24
|
+
?wiki_id: String?,
|
|
25
|
+
?api_key_id: String?,
|
|
26
|
+
?secret: String?,
|
|
27
|
+
?password: String?,
|
|
28
|
+
?json: bool,
|
|
29
|
+
?verbose: bool,
|
|
30
|
+
?debug: bool
|
|
31
|
+
) -> void
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class Get < Base
|
|
35
|
+
def call: (
|
|
36
|
+
page_name: String,
|
|
37
|
+
?output_file: String?,
|
|
38
|
+
?force: bool,
|
|
39
|
+
?out: IO,
|
|
40
|
+
?err: IO,
|
|
41
|
+
?wiki_id: String?,
|
|
42
|
+
?api_key_id: String?,
|
|
43
|
+
?secret: String?,
|
|
44
|
+
?password: String?,
|
|
45
|
+
?verbose: bool,
|
|
46
|
+
?debug: bool
|
|
47
|
+
) -> void
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class Put < Base
|
|
51
|
+
def call: (
|
|
52
|
+
page_name: String,
|
|
53
|
+
?input_file: String?,
|
|
54
|
+
?out: IO,
|
|
55
|
+
?err: IO,
|
|
56
|
+
?wiki_id: String?,
|
|
57
|
+
?api_key_id: String?,
|
|
58
|
+
?secret: String?,
|
|
59
|
+
?password: String?,
|
|
60
|
+
?verbose: bool,
|
|
61
|
+
?debug: bool
|
|
62
|
+
) -> void
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|