-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
53 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,39 @@ | ||
import subprocess | ||
import sys | ||
|
||
import code_manager.utils.logger | ||
from code_manager.core.configuration import ConfigurationAware | ||
from code_manager.utils.logger import RED | ||
from code_manager.utils.logger import RESET | ||
|
||
class GrepCommand: | ||
|
||
class GrepCommand(ConfigurationAware): | ||
|
||
name = 'grep' | ||
|
||
def __init__(self): | ||
self.color = False if self.opt.get('Commands', 'grep-colors', fallback=True) == 'false' else True | ||
|
||
def execute(self, args, path): | ||
grep_command = ['grep', '-r'] | ||
|
||
if self.color and not args.no_color: | ||
color = True | ||
grep_command.append('--color=always') | ||
elif args.no_color: | ||
color = False | ||
grep_command.append('--color=never') | ||
|
||
ret = subprocess.run(['grep', '-r', *args], stdout=subprocess.PIPE, cwd=path) | ||
grep_command.extend(args.rest) | ||
ret = subprocess.run(grep_command, stdout=subprocess.PIPE, cwd=path) | ||
|
||
for line in ret.stdout.splitlines(): | ||
sys.stdout.buffer.write(bytes(self.pack + ':', 'utf-8') + line + b'\n') | ||
sys.stdout.buffer.flush() | ||
if color: | ||
sys.stdout.buffer.write(bytes(RED + self.pack + RESET + ':', 'utf-8') + line + b'\n') | ||
else: | ||
sys.stdout.buffer.write(bytes(self.pack + ':', 'utf-8') + line + b'\n') | ||
sys.stdout.buffer.flush() | ||
|
||
return 0 | ||
return 0 | ||
|
||
|
||
ExportedClass = GrepCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import subprocess | ||
import os | ||
import sys | ||
import subprocess | ||
|
||
import code_manager.utils.logger | ||
|
||
class PushCommand: | ||
|
||
name = 'push' | ||
|
||
def execute(self, args, path): | ||
if not os.path.exists(os.path.join(path, '.git')): | ||
return 0 | ||
ret = subprocess.run(['git', 'push', *args], stdout=subprocess.STDOUT, cwd=path) | ||
return 0 | ||
return 0 | ||
|
||
|
||
ExportedClass = PushCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import subprocess | ||
import sys | ||
|
||
import code_manager.utils.logger | ||
|
||
class SedCommand: | ||
|
||
name = 'sed' | ||
|
||
def execute(self, args, path): | ||
ret = subprocess.run(['sed', *args], stdout=subprocess.PIPE, cwd=path) | ||
return 0 | ||
ret = subprocess.run(['sed', *args], stdout=subprocess.PIPE, cwd=path) | ||
return 0 | ||
|
||
|
||
ExportedClass = SedCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters