Skip to content

Commit 5c3bc2b

Browse files
committed
update
1 parent ac45068 commit 5c3bc2b

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed

GtkFileGenerator/Program.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ public static void Main(string[] args)
2727
throw;
2828
}
2929

30-
//clsArgsConfig.Instance().ProjectFolder = "/home/ita/C#/App_GitHub/GtkFileGenerator/GtkFileGenerator";
31-
//clsArgsConfig.Instance().ProjectName = "GtkFileGenerator";
32-
3330
if (!clsArgsConfig.Instance()._validateCommandKey())
3431
{
3532
return;

GtkFileGenerator/clsArgsConfig.cs

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
34
using System.Linq;
45
using System.Xml;
56

@@ -24,6 +25,7 @@ public static clsArgsConfig Instance()
2425
"-projectName","-projectDir"};
2526
public Boolean _validateCommandKey()
2627
{
28+
2729
if (ProjectFolder == "" )
2830
{
2931
Console.WriteLine("The projectFolder is not specified.");
@@ -34,6 +36,11 @@ public Boolean _validateCommandKey()
3436
Console.WriteLine("ProjectName is not specified.");
3537
return false;
3638
}
39+
40+
if (ProjectName != "")
41+
{
42+
ProjectName = _getProjectName(ProjectName);
43+
}
3744

3845
return true;
3946
}
@@ -53,7 +60,7 @@ public void _setArgs(string[] args)
5360
i++;
5461
continue;
5562
}
56-
63+
5764
if (commandKey._indexOf("-projectName") != -1)
5865
{
5966

@@ -70,7 +77,37 @@ public void _setArgs(string[] args)
7077
}
7178
}
7279

73-
74-
80+
/// <summary>
81+
/// プロジェクトパスを取得する
82+
/// </summary>
83+
/// <param name="path"></param>
84+
/// <returns></returns>
85+
private string _getProjectName(string path)
86+
{
87+
path = path.TrimEnd(Path.DirectorySeparatorChar);
88+
89+
var separator = Path.DirectorySeparatorChar;
90+
string[] pathArray = path.Split(separator);
91+
92+
if (pathArray.Length == 0)
93+
{
94+
return path;
95+
}
96+
97+
for (int i = pathArray.Length; i > 0; i--)
98+
{
99+
var pathArray1 = pathArray[0..i];
100+
string stCsvData = string.Join("/", pathArray1);
101+
string csprojPath = stCsvData + "/" + pathArray[i - 1] + ".csproj";
102+
if (File.Exists(csprojPath))
103+
{
104+
return pathArray[i - 1];
105+
break;
106+
}
107+
}
108+
109+
return "";
110+
}
111+
75112
}
76113
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $ dotnet new --install GtkSharp.Template.CSharp
2929
Run from a terminal You can't use macros in a terminal, so you need to put the absolute path in the projectDir.
3030

3131
```
32-
$ GtkFileGenerator -projectName namespace name -projectDir projectPath
32+
$ GtkFileGenerator -projectName namespace -projectDir projectPath
3333
```
3434

3535
##### Run from Rider macro can be used
@@ -42,7 +42,7 @@ Set the path of the program.
4242
Set the arguments.
4343

4444
```
45-
-projectName $SolutionName$ -projectDir $FileDir$
45+
-projectName $FilePath$ -projectDir $FileDir$
4646
```
4747

4848
The working Path can be empty.

0 commit comments

Comments
 (0)