Skip to content

Commit

Permalink
Internal: Refactor: Sort commands
Browse files Browse the repository at this point in the history
  • Loading branch information
gerardroche committed Aug 27, 2017
1 parent dc06597 commit f83e959
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## Unreleased
## [1.6.0] - 2017-08-27

### Added

Expand Down Expand Up @@ -174,6 +174,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt

* Initial import

[1.6.0]: https://github.com/gerardroche/sublime-open-sesame/compare/1.5.7...1.6.0
[1.5.7]: https://github.com/gerardroche/sublime-open-sesame/compare/1.5.6...1.5.7
[1.5.6]: https://github.com/gerardroche/sublime-open-sesame/compare/1.5.5...1.5.6
[1.5.5]: https://github.com/gerardroche/sublime-open-sesame/compare/1.5.4...1.5.5
Expand Down
58 changes: 29 additions & 29 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,6 @@
from sublime_plugin import WindowCommand


class OpenSesameOpenProjectCommand(WindowCommand):

def run(self, path=None, *args, **kwargs):
self.folders = _find_folders(path)
if self.folders:
self.window.show_quick_panel(self.folders, self.on_done)
else:
_status_message('no projects found')

def on_done(self, index):
if index == -1:
return

folder = self.folders[index][1]
folder_projects = glob.glob(folder + '/*.sublime-project')

if len(folder_projects) == 1 and os.path.isfile(folder_projects[0]):
_subl_open_project_in_new_window(folder_projects[0])
elif os.path.isdir(folder):
_subl_open_folder_in_new_window(folder)


# DEPRECATED Remove in v2.0.0
class OpenSesameCommand(OpenSesameOpenProjectCommand):
def run(self, *args, **kwargs):
_message('***DEPRECATED*** \'open_sesame\' command is deprecated; use \'open_sesame_open_project\'')
super().run(*args, **kwargs)


class OpenSesameAddProjectCommand(WindowCommand):

def run(self, path=None, *args, **kwargs):
Expand Down Expand Up @@ -88,6 +59,35 @@ def run(self, *args, **kwargs):
super().run(*args, **kwargs)


class OpenSesameOpenProjectCommand(WindowCommand):

def run(self, path=None, *args, **kwargs):
self.folders = _find_folders(path)
if self.folders:
self.window.show_quick_panel(self.folders, self.on_done)
else:
_status_message('no projects found')

def on_done(self, index):
if index == -1:
return

folder = self.folders[index][1]
folder_projects = glob.glob(folder + '/*.sublime-project')

if len(folder_projects) == 1 and os.path.isfile(folder_projects[0]):
_subl_open_project_in_new_window(folder_projects[0])
elif os.path.isdir(folder):
_subl_open_folder_in_new_window(folder)


# DEPRECATED Remove in v2.0.0
class OpenSesameCommand(OpenSesameOpenProjectCommand):
def run(self, *args, **kwargs):
_message('***DEPRECATED*** \'open_sesame\' command is deprecated; use \'open_sesame_open_project\'')
super().run(*args, **kwargs)


class OpenSesameRemoveFolderCommand(WindowCommand):

def run(self, *args, **kwargs):
Expand Down

0 comments on commit f83e959

Please sign in to comment.