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
|
# File 'lib/wiki_tips_post/helper_command.rb', line 26
def post
begin
tag_array = input[:tags].split(',')
rescue StandardError => e
puts "Wrong tag format, it should be string split with ,"
end
tip_content = nil
if input[:file]
tip_content = File.read File.expand_path(input[:file])
end
@wikiposter = WikiPostHelper.new(
:title => input[:title],
:tips => tip_content || input[:tip],
:tags => tag_array
)
puts "\ncloning repo..."
@wikiposter.prepare_repo
puts "\ncreating post..."
@wikiposter.create_post
puts "\npushing repo..."
push_repo_success = @wikiposter.push_to_repo
if push_repo_success
puts "\nremoving temporary clone of repo..."
@wikiposter.delete_local_repo_clone
puts "\nsuccessfully added tip!"
else
puts "\npush was NOT successful"
exit 1
end
end
|