18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/readwise/cli/document/create_command.rb', line 18
def add_options(opts)
opts.on("-f", "--html-file=FILE", "HTML file path") do |file|
options[:file] = file
end
opts.on("--title=TITLE", "Document title") do |title|
options[:title] = title
end
opts.on("--author=AUTHOR", "Document author") do |author|
options[:author] = author
end
opts.on("-u", "--url=URL", "Source URL (defaults to https://example.com/<filename>)") do |url|
unless valid_url?(url)
puts "Error: Invalid URL format. Please provide a valid URL."
exit 1
end
options[:url] = url
end
opts.on("--summary=SUMMARY", "Document summary") do |summary|
options[:summary] = summary
end
opts.on("--notes=NOTES", "Personal notes") do |notes|
options[:notes] = notes
end
opts.on("--location=LOCATION", "Document location: #{Readwise::Constants::DOCUMENT_LOCATIONS.join(', ')} (default: new)") do |location|
unless Readwise::Constants::DOCUMENT_LOCATIONS.include?(location)
puts "Error: Invalid location. Must be one of: #{Readwise::Constants::DOCUMENT_LOCATIONS.join(', ')}"
exit 1
end
options[:location] = location
end
opts.on("--category=CATEGORY", "Document category: #{Readwise::Constants::DOCUMENT_CATEGORIES.join(', ')}") do |category|
unless Readwise::Constants::DOCUMENT_CATEGORIES.include?(category)
puts "Error: Invalid category. Must be one of: #{Readwise::Constants::DOCUMENT_CATEGORIES.join(', ')}"
exit 1
end
options[:category] = category
end
opts.on("--tags=TAGS", "Comma-separated list of tags") do |tags|
options[:tags] = tags.split(',').map(&:strip)
end
opts.on("--image-url=URL", "Image URL") do |image_url|
options[:image_url] = image_url
end
opts.on("--published-date=DATE", "Published date (ISO 8601 format)") do |date|
unless valid_iso8601_date?(date)
puts "Error: Invalid date format. Please provide a valid ISO 8601 date (e.g., 2023-12-25T10:30:00Z)."
exit 1
end
options[:published_date] = date
end
opts.on("--[no-]clean-html", "Clean HTML (default: true)") do |clean|
options[:should_clean_html] = clean
end
opts.on("--saved-using=SOURCE", "Saved using source (default: cli)") do |source|
options[:saved_using] = source
end
end
|