Skip to content

Add delete_local_all command #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ commands
gisty sync sync remote gist. (clone all remote gist)
gisty sync_delete sync remote gist. delete local gist if remote gist was deleted.
gisty pull_all pull all gist.
gisty delete_local_all delete all local gist.
gisty about show about gisty
gisty help show help

Expand Down
2 changes: 1 addition & 1 deletion gisty.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |s|
s.email = "http://mailhide.recaptcha.net/d?k=01AhB7crgrlHptVaYRD0oPwA==&c=L_iqOZrGmo6hcGpPTFg1QYnjr-WpAStyQ4Y8ShfgOHs="
s.executables = ["gisty"]
s.extra_rdoc_files = ["README.rdoc"]
s.files = ["README.rdoc", "Rakefile", "bin/gisty", "test/fixtures", "test/fixtures/bar.user.js", "test/fixtures/foo.user.js", "test/fixtures/gists_1", "test/fixtures/gists_2", "test/fixtures/gists_3", "test/fixtures/gists_post", "test/gisty_test.rb", "test/test_helper.rb", "lib/commands", "lib/commands/about.rb", "lib/commands/gyast.rb", "lib/commands/help.rb", "lib/commands/list.rb", "lib/commands/post.rb", "lib/commands/private_post.rb", "lib/commands/pull_all.rb", "lib/commands/sync.rb", "lib/commands/sync_delete.rb", "lib/gisty.rb"]
s.files = ["README.rdoc", "Rakefile", "bin/gisty", "test/fixtures", "test/fixtures/bar.user.js", "test/fixtures/foo.user.js", "test/fixtures/gists_1", "test/fixtures/gists_2", "test/fixtures/gists_3", "test/fixtures/gists_post", "test/gisty_test.rb", "test/test_helper.rb", "lib/commands", "lib/commands/about.rb", "lib/commands/delete_local_all.rb", "lib/commands/gyast.rb", "lib/commands/help.rb", "lib/commands/list.rb", "lib/commands/post.rb", "lib/commands/private_post.rb", "lib/commands/pull_all.rb", "lib/commands/sync.rb", "lib/commands/sync_delete.rb", "lib/gisty.rb"]
s.homepage = "http://github.com/swdyh/gisty/tree/master"
s.rdoc_options = ["--title", "gisty documentation", "--charset", "utf-8", "--line-numbers", "--main", "README.rdoc", "--inline-source", "--exclude", "^(examples|extras)/"]
s.require_paths = ["lib"]
Expand Down
5 changes: 5 additions & 0 deletions lib/commands/delete_local_all.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmd :delete_local_all, '', 'delete all local gist' do
@g.delete_local_all
puts '---'
puts 'delete_local_all finished.'
end
12 changes: 12 additions & 0 deletions lib/gisty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ def delete id
FileUtils.rm_rf @dir.join(id) if @dir.join(id).exist?
end

def delete_local_all
local = local_ids
FileUtils.cd @dir do
if local.size > 0
local.each do |id|
puts "delete #{id}"
delete id
end
end
end
end

def sync delete = false
local = local_ids
FileUtils.cd @dir do
Expand Down