Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing iwd dependencies to .txt #1

Open
kryptoxide opened this issue Aug 13, 2023 · 1 comment
Open

Writing iwd dependencies to .txt #1

kryptoxide opened this issue Aug 13, 2023 · 1 comment

Comments

@kryptoxide
Copy link

When using the command 'iwdfiles mp_terminal'

Output:
"Successfully wrote all referenced iwd-files in mp_terminal_iwd.txt"

The output text file is unfortunately blank, I have fully processed the 'update' command.

@kryptoxide
Copy link
Author

It seems like the issue might be related to the regular expression not matching the expected pattern in the output of the command. Let's take a closer look at the regular expression and the output to troubleshoot the problem.

The regular expression used in your code is:

var reg = new Regex(@"(\([a-z]+ [0-9]\)) (.*)");

This regex is meant to match lines that have a format like "([a-z] [0-9]) asset_name". Make sure that the output you're trying to parse matches this pattern exactly. If the pattern in the output is different, the regex won't be able to capture the asset names correctly.

To troubleshoot:

  1. Check Output Format: Examine the actual output from the command that is being captured in the output variable. Make sure it matches the expected format of the regex.

  2. Adjust Regex Pattern: If the output format is different, you might need to adjust the regular expression pattern to match the actual output format. If the asset names are enclosed in double quotes or brackets, for example, you would need to adjust the regex pattern accordingly.

  3. Debugging: Add some debugging statements to print the captured output before attempting to process it with the regular expression. This can help you visually confirm the format and identify any mismatches.

Here's an example of how you can add debugging statements to your code to help diagnose the issue:

// ... (previous code)

if (result == 0)
{
    // Add this line to debug the captured output
    cli.WriteLine($"Captured Output:\n{output}");

    var dumpFile = $"{zoneName}_iwd.txt";

    using (FileStream fs = new FileStream(dumpFile, FileMode.Create))
    {
        using (StreamWriter sw = new StreamWriter(fs))
        {
            var reg = new Regex(@"(\([a-z]+ [0-9]\)) (.*)");
            var matches = reg.Matches(output);

            foreach (Match match in matches)
            {
                // ... (remaining code)
            }
        }
    }

    // ... (remaining code)
}
else
{
    // ... (remaining code)
}

By examining the captured output and potentially adjusting the regular expression pattern, you should be able to resolve the issue of the blank .txt file being generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant