diff --git a/index.ts b/index.ts index 5fc92b3..6e9f842 100644 --- a/index.ts +++ b/index.ts @@ -1,13 +1,18 @@ #!/usr/bin/env node -import { evaluateSearchQuery } from './src/evaluator' +import { evaluateSearchQuery, type FunctionDetail } from './src/evaluator' import { parse } from './src/lexer' import { prettify } from './src/prettyfier' const tsConfigFilePath = process.argv[2] const userSearchQuery = process.argv[3] -export function tsoogle (tsConfigFilePath: string, userSearchQuery: string): string { +export function tsoogle (tsConfigFilePath: string, userSearchQuery: string): FunctionDetail[] { + const searchQuery = parse(userSearchQuery) + return evaluateSearchQuery(tsConfigFilePath, searchQuery) +} + +export function tsoogleCmd (tsConfigFilePath: string, userSearchQuery: string): string { const searchQuery = parse(userSearchQuery) let output = '' evaluateSearchQuery(tsConfigFilePath, searchQuery).forEach(func => { @@ -16,4 +21,6 @@ export function tsoogle (tsConfigFilePath: string, userSearchQuery: string): str return output } -console.log(tsoogle(tsConfigFilePath, userSearchQuery)) +if (tsConfigFilePath !== undefined && userSearchQuery !== undefined) { + console.log(tsoogleCmd(tsConfigFilePath, userSearchQuery)) +} diff --git a/package.json b/package.json index 4a4b822..879e7dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stanimirovv/tsoogle", - "version": "1.0.4", + "version": "1.0.7", "description": "Find functions or methods by approximate signature - return type, argument types or both. Supports optional arguments, rest arguments and partial type checking.", "main": "dist/index.js", "bin": "dist/index.js",