11using System ;
2+ using System . CommandLine ;
3+ using System . CommandLine . Invocation ;
24using System . Threading . Tasks ;
35using Strazh . Analysis ;
46using Strazh . Database ;
@@ -7,7 +9,25 @@ namespace Strazh
79{
810 class Program
911 {
10- static async Task Main ( string [ ] args )
12+ static async Task Main ( params string [ ] args )
13+ {
14+ var rootCommand = new RootCommand ( ) ;
15+
16+ var optionPath = new Option < string > ( "--path" , "absolute path to .csproj file" ) ;
17+ optionPath . AddAlias ( "-p" ) ;
18+ optionPath . IsRequired = true ;
19+ rootCommand . Add ( optionPath ) ;
20+
21+ var optionCred = new Option < string > ( "--credentials" , "credentials of `dbname:user:password` to connect to Neo4j batabase" ) ;
22+ optionCred . AddAlias ( "-c" ) ;
23+ rootCommand . Add ( optionCred ) ;
24+
25+ rootCommand . Handler = CommandHandler . Create < string , string > ( BuildKnowledgeGraph ) ;
26+
27+ await rootCommand . InvokeAsync ( args ) ;
28+ }
29+
30+ static async Task BuildKnowledgeGraph ( string path , string credentials )
1131 {
1232 try
1333 {
@@ -17,10 +37,9 @@ static async Task Main(string[] args)
1737 Console . WriteLine ( "Strazh disappointed. There is no Neo4j instance ready to use." ) ;
1838 return ;
1939 }
20- Console . WriteLine ( "Brewing the Knowledge Graph..." ) ;
21- var triples = await Analyzer . Analyze ( args [ 0 ] ) ;
22- await DbManager . InsertData ( triples ) ;
23- Console . WriteLine ( "Enjoy the Knowledge Graph of your codebase!" ) ;
40+ Console . WriteLine ( "Brewing the Knowledge Graph." ) ;
41+ var triples = await Analyzer . Analyze ( path ) ;
42+ await DbManager . InsertData ( triples , credentials ) ;
2443 }
2544 catch ( Exception ex )
2645 {
0 commit comments