<commit_before>﻿using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using UnityLauncherTools;

namespace UnityLauncher
{
    public partial class Form1 : Form
    {
        public static Dictionary<string, string> unityList = new Dictionary<string, string>();
        const string contextRegRoot = "Software\\Classes\\Directory\\Background\\shell";
        const string launcherArgumentsFile = "LauncherArguments.txt";
        const string githubReleaseAPICheckURL = "https://api.github.com/repos/unitycoder/unitylauncher/releases/latest";
        const string githubReleasesLinkURL = "https://github.com/unitycoder/UnityLauncher/releases";

        bool isDownloadUnityList = false;
        string previousGitRelease = "0";


        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Start();
        }

        void Start()
        {
            SetStatus("Initializing..");
            // check installations folder
            var root = GetUnityInstallationsRootFolder();
            if (root == null || root.Length == 0)
            {
                SetStatus("Missing root folder..");
                AddUnityInstallationRootFolder();
                SetStatus("Ready");
            }

            LoadSettings();

            // scan installed unitys
            bool foundedUnitys = ScanUnityInstallations();
            if (foundedUnitys == false)
            {
                SetStatus("Error> Did not found any Unity installations, try setting correct root folder..");
                UpdateRecentProjectsList();
                tabControl1.SelectedIndex = tabControl1.TabCount - 1; // last tab is settings
                return;
            }

            // check if received -projectPath argument (that means opening from explorer / cmdline)
            string[] args = Environment.GetCommandLineArgs();
            if (args != null && args.Length > 2)
            {
                // first argument needs to be -projectPath
                var commandLineArgs = args[1];
                if (commandLineArgs == "-projectPath")
                {
                    SetStatus("Launching from commandline..");

                    // path
                    var projectPathArgument = args[2];

                    var version = Tools.GetProjectVersion(projectPathArgument);

                    // take extra arguments also
                    var commandLineArguments = "";
                    for (int i = 3, len = args.Length; i < len; i++)
                    {
                        commandLineArguments += " " + args[i];
                    }
<commit_msg>Support relative paths from command line<commit_after>﻿using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using UnityLauncherTools;

namespace UnityLauncher
{
    public partial class Form1 : Form
    {
        public static Dictionary<string, string> unityList = new Dictionary<string, string>();
        const string contextRegRoot = "Software\\Classes\\Directory\\Background\\shell";
        const string launcherArgumentsFile = "LauncherArguments.txt";
        const string githubReleaseAPICheckURL = "https://api.github.com/repos/unitycoder/unitylauncher/releases/latest";
        const string githubReleasesLinkURL = "https://github.com/unitycoder/UnityLauncher/releases";

        bool isDownloadUnityList = false;
        string previousGitRelease = "0";


        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Start();
        }

        void Start()
        {
            SetStatus("Initializing..");
            // check installations folder
            var root = GetUnityInstallationsRootFolder();
            if (root == null || root.Length == 0)
            {
                SetStatus("Missing root folder..");
                AddUnityInstallationRootFolder();
                SetStatus("Ready");
            }

            LoadSettings();

            // scan installed unitys
            bool foundedUnitys = ScanUnityInstallations();
            if (foundedUnitys == false)
            {
                SetStatus("Error> Did not found any Unity installations, try setting correct root folder..");
                UpdateRecentProjectsList();
                tabControl1.SelectedIndex = tabControl1.TabCount - 1; // last tab is settings
                return;
            }

            // check if received -projectPath argument (that means opening from explorer / cmdline)
            string[] args = Environment.GetCommandLineArgs();
            if (args != null && args.Length > 2)
            {
                // first argument needs to be -projectPath
                var commandLineArgs = args[1];
                if (commandLineArgs == "-projectPath")
                {
                    SetStatus("Launching from commandline..");

                    // path
                    var projectPathArgument = args[2];

                    // resolve full path if path parameter isn't a rooted path
                    if (!Path.IsPathRooted(projectPathArgument))
                    {
                        projectPathArgument = Directory.GetCurrentDirectory() + projectPathArgument;
                    }

                    var version = Tools.GetProjectVersion(projectPathArgument);

                    // take extra arguments also
                    var commandLineArguments = "";
                    for (int i = 3, len = args.Length; i < len; i++)
                    {
                        commandLineArguments += " " + args[i];
                    }

{'fraction_non_alphanumeric': 0.08931185944363104, 'fraction_numerical': 0.004555067512607776, 'mean_word_length': 1.7631460674157304, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4763494', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1375, 'n_words': 382}