Skip to content

Commit

Permalink
feat(command): add isApplicable method to ShireCommand
Browse files Browse the repository at this point in the history
Introduce a default `isApplicable` method in `ShireCommand` interface and override it in `RipgrepSearchShireCommand` to check for ripgrep binary availability.
  • Loading branch information
phodal committed Feb 2, 2025
1 parent bafff1b commit 4857af8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import com.phodal.shirelang.compiler.execute.command.search.RipgrepSearcher
class RipgrepSearchShireCommand(
val myProject: Project, private val scope: String, val text: String?,
) : ShireCommand {
override fun isApplicable(): Boolean {
return RipgrepSearcher.findRipgrepBinary() != null
}

override suspend fun doExecute(): String? {
val searchDirectory = myProject.baseDir!!.path
return RipgrepSearcher.searchFiles(myProject, searchDirectory, text ?: scope, null).get()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.phodal.shirelang.compiler.execute.command

interface ShireCommand {
fun isApplicable(): Boolean {
return true
}

suspend fun doExecute(): String?
}

0 comments on commit 4857af8

Please sign in to comment.