Class: Command::Remove
- Inherits:
-
CommandBase
- Object
- CommandBase
- Command::Remove
- Defined in:
- lib/command/remove.rb
Instance Method Summary collapse
- #execute(argv) ⇒ Object
-
#initialize ⇒ Remove
constructor
A new instance of Remove.
- #oneline_help ⇒ Object
Methods inherited from CommandBase
Constructor Details
#initialize ⇒ Remove
Returns a new instance of Remove.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/command/remove.rb', line 11 def initialize super("<target> [<target2> ...] [options]") @opt.separator <<-EOS ・削除したい小説のNコード、URL、タイトルもしくはIDを指定して下さい。 IDは #{@opt.program_name} list を参照して下さい。 ・一度に複数の小説を指定する場合は空白で区切って下さい。 ・削除確認をスキップするには -y オプションを有効にして下さい。 ・削除するのはデータベースのインデックスだけで、変換済みテキストファイルやMOBIファイル等はそのまま残ります。 Example: narou remove n9669bk narou remove http://ncode.syosetu.com/n9669bk/ narou remove n9669bk http://ncode.syosetu.com/n4259s/ narou remove 0 1 -y narou remove n9669bk --with-file # ファイルも完全に削除する Options: EOS @opt.on("-y", "--yes", "削除確認メッセージを表示しない") { @options["yes"] = true } @opt.on("--with-file", "小説の保存フォルダ・ファイルも全て削除する") { @options["with-file"] = true } end |
Instance Method Details
#execute(argv) ⇒ Object
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 |
# File 'lib/command/remove.rb', line 38 def execute(argv) super if argv.empty? puts @opt.help return end argv.each_with_index do |target, i| Helper.print_horizontal_rule if i > 0 data = Downloader.get_data_by_target(target) unless data error "#{target} は存在しません" next end title = data["title"] if Narou.novel_frozen?(target) puts "#{title} は凍結中です\n削除を中止しました" next end unless @options["yes"] next unless Helper.confirm("#{title} を#{(@options["with-file"] ? "“完全に”" : "")}削除しますか") end Downloader.remove_novel(target, @options["with-file"]) puts "<green>#{title} を削除しました</green>".termcolor end end |
#oneline_help ⇒ Object
64 65 66 |
# File 'lib/command/remove.rb', line 64 def oneline_help "小説を削除します" end |