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
|
# File 'lib/command/flag.rb', line 18
def initialize
super("<attribute> <target> [<target2> ...]")
@opt.separator <<-EOS.termcolor
<bold><red>非推奨のコマンドです。tagコマンドを使用して下さい
flagコマンドはv.1.7.0で廃止予定です
flagデータをtagデータに移行するには、
narou flag --convert-tag
を実行して下さい</red></bold>
・指定した小説に各種フラグを設定します
・再実行で解除
・--on, --off オプションを付けることで強制設定可能
・現在指定可能なフラグ
end : 小説が完結状態
delete: 削除された状態
Examples:
narou flag end 100 # ID:100の小説を完結状態にする
narou flag end --on 100 # 現在の状態に関わらず完結状態にする
Options:
EOS
@opt.on("--on", "強制的にフラグを立てる") {
@options["on"] = true
}
@opt.on("--off", "強制的にフラグをはずす") {
@options["off"] = true
}
@opt.on("--convert-tag", "flagデータをtagデータに移行します") {
modify = false
database = Database.instance
database.each do |id, data|
if data["flags"]
tags = data["flags"].keys
tags << "404" if tags.delete("delete")
unless tags.empty?
Tag.execute!([id, "--add", tags.join(" "), "--color", "white"])
end
puts "-" * 70
data.delete("flags")
modify = true
end
end
if modify
database.save_database
puts "移行が完了しました"
end
exit 0
}
end
|