-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
isolated functionality so we can in the future separate this into Cor…
…e, Command Line Interface, and Editor Plugin
- Loading branch information
1 parent
88fa28b
commit 7863bfb
Showing
11 changed files
with
251 additions
and
177 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
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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
using System; | ||
|
||
namespace agsget | ||
{ | ||
public class ApplyDo | ||
{ | ||
public static int Do(string changeRunDir, string packageName) | ||
{ | ||
BaseFiles.SetRunDirectory(changeRunDir); | ||
|
||
//1. If no PACKAGE_NAME is provided, exit with error. | ||
// maybe the required keyword protects and we don't need this | ||
if (string.IsNullOrEmpty(packageName) == true) | ||
{ | ||
Console.WriteLine("No Package Specified, will do nothing."); | ||
return 1; | ||
} | ||
|
||
//2. Check if the command is run from a folder containing a valid Game.agf project. If not, exit with error. | ||
if (!GameAgfIO.Valid()) | ||
{ | ||
Console.WriteLine("Not an AGS Game root directory."); | ||
Console.WriteLine("You can only get packages for an AGS Game project."); | ||
return 1; | ||
} | ||
|
||
//3. Check if AGS Editor is open by looking for a lockfile in the folder, if it is, exit with error. | ||
if (GameAgfIO.IsProjectOpenOnAGSEditor()) | ||
{ | ||
Console.WriteLine("AGS Editor is open on project file."); | ||
Console.WriteLine("Close AGS Editor, and try again."); | ||
return 1; | ||
} | ||
|
||
//4. Check if a package index exists on `./ ags_packages_cache / package_index`, | ||
// if not, it runs the functionality from `agsget update`. | ||
if(!BaseFiles.ExistsIndexFile()) | ||
{ | ||
//Update.2.If it is, creates a folder `./ ags_packages_cache /` on the directory if it doesn't exist. | ||
BaseFiles.CreatePackageDirIfDoesntExist(); | ||
|
||
//Update.3.Downloads the index of packages to `./ ags_packages_cache / package_index`. | ||
//If it already exists, overwrites it. | ||
PackageCacheIO.GetPackageIndex(null); | ||
} | ||
|
||
//5. Check if PACKAGE_NAME exists on `./ ags_packages_cache / PACKAGE_NAME`, | ||
// if not, exit with error Download PACKAGE_NAME to `./ ags_packages_cache / PACKAGE_NAME`. | ||
//6.If download doesn't complete, exit with error. | ||
if (!PackageCacheIO.IsPackageOnLocalCache(packageName)) | ||
{ | ||
//Get.4. Check if PACKAGE_NAME exists on `./ ags_packages_cache / package_index`, if not, exit with error. | ||
if (!PackageCacheIO.PackageOnIndex(packageName)) | ||
{ | ||
Console.WriteLine("Package {0} not found on package index.", packageName); | ||
Console.WriteLine("If you are sure you spelled correctly, try updating your local package index."); | ||
return 1; | ||
} | ||
|
||
//Get.5. Download PACKAGE_NAME to `./ags_packages_cache/PACKAGE_NAME`. | ||
if (!PackageCacheIO.GetPackage( | ||
Configuration.PackageIndexURL, | ||
packageName)) | ||
{ | ||
Console.WriteLine("Error downloading package {0}.", packageName); | ||
return 1; | ||
} | ||
} | ||
|
||
|
||
//7.Check if a script pair with the same name already exists on Game.agf, | ||
// if there is, ask about update, if the answer is no, exit with error. | ||
if (GameAgfIO.IsScriptPairInserted(packageName)) | ||
{ | ||
Console.WriteLine("Script already found on Game.agf."); | ||
if (!ConsoleExtra.ConfirmYN("Are you sure you want to replace?")) | ||
{ | ||
Console.WriteLine("Package already inserted and will not be replaced."); | ||
return 1; | ||
} | ||
} | ||
|
||
//8.Check if script pairs with the same name of dependencies already exists on Game.agf, | ||
// and if they are above insert position, if they are not, exit with error. | ||
|
||
//9.If dependencies are already the in Game.agf, ask the user if he | ||
//wants to proceed, if not, exit with error. | ||
|
||
//10.Insert or replace the script and dependencies in Game.agf, and | ||
// copy(or overwrite) script pairs in the project folder. | ||
|
||
|
||
Console.WriteLine("NOT IMPLEMENTED YET"); | ||
Console.WriteLine("Install Package: '{0}'", packageName); | ||
|
||
if (string.IsNullOrEmpty(packageName) == true) | ||
{ | ||
Console.WriteLine("No Package Specified, will do nothing."); | ||
return 1; | ||
} | ||
|
||
Console.WriteLine(); | ||
return 0; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
|
||
namespace agsget | ||
{ | ||
public class GetDo | ||
{ | ||
public static int Do(string changeRunDir, string packageName) | ||
{ | ||
BaseFiles.SetRunDirectory(changeRunDir); | ||
|
||
//1. If no PACKAGE_NAME is provided, exit with error. | ||
// maybe the required keyword protects and we don't need this | ||
if (string.IsNullOrEmpty(packageName) == true) | ||
{ | ||
Console.WriteLine("No Package Specified, will do nothing."); | ||
return 1; | ||
} | ||
|
||
//2. Check if the command is run from a folder containing a valid Game.agf project. If not, exit with error. | ||
if (!GameAgfIO.Valid()) | ||
{ | ||
Console.WriteLine("Not an AGS Game root directory."); | ||
Console.WriteLine("You can only get packages for an AGS Game project."); | ||
return 1; | ||
} | ||
|
||
//3. Check if a package index exists on `./ags_packages_cache/package_index`, if not, it runs the functionality from `agsget update`. | ||
if(!BaseFiles.ExistsIndexFile()) | ||
{ | ||
//Update.2.If it is, creates a folder `./ ags_packages_cache /` on the directory if it doesn't exist. | ||
BaseFiles.CreatePackageDirIfDoesntExist(); | ||
|
||
//Update.3.Downloads the index of packages to `./ ags_packages_cache / package_index`. | ||
//If it already exists, overwrites it. | ||
PackageCacheIO.GetPackageIndex(null); | ||
} | ||
|
||
//4.Check if PACKAGE_NAME exists on `./ ags_packages_cache / package_index`, if not, exit with error. | ||
if (!PackageCacheIO.PackageOnIndex(packageName)) | ||
{ | ||
Console.WriteLine("Package {0} not found on package index.", packageName); | ||
Console.WriteLine("If you are sure you spelled correctly, try updating your local package index."); | ||
return 1; | ||
} | ||
|
||
//5. Download PACKAGE_NAME to `./ags_packages_cache/PACKAGE_NAME`. | ||
if(!PackageCacheIO.GetPackage( | ||
Configuration.PackageIndexURL, | ||
packageName)) | ||
{ | ||
Console.WriteLine("Error downloading package {0}.", packageName); | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
|
||
namespace agsget | ||
{ | ||
public class PackDo | ||
{ | ||
public static int Do(string changeRunDir, string pairName) | ||
{ | ||
Console.WriteLine("NOT IMPLEMENTED YET"); | ||
Console.WriteLine("Create Package: '{0}'", pairName); | ||
|
||
if (string.IsNullOrEmpty(pairName) == true) | ||
{ | ||
Console.WriteLine("No Script Pair Name Specified, will do nothing."); | ||
return 1; | ||
} | ||
|
||
Console.WriteLine(); | ||
return 0; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.