//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// UserRTX.NET satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Diagnostics;
using System.ComponentModel;

#if !WASM
namespace user_rtx { using u = user_rtx;
#else
namespace user_rtx.wasm { using u = user_rtx.wasm;
#endif

/// <summary>
/// Shell helpers (static class)
/// </summary>
public static class shell {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="ArgumentException" />
/// <exception cref="Win32Exception" />
/// <exception cref="PlatformNotSupportedException" />
public static Process? OpenUri( string uri ) =>
   Process.Start( StartupInfoFromUri( uri ) );

/// <exception cref="ArgumentException" />
/// <exception cref="PlatformNotSupportedException" />
public static ProcessStartInfo StartupInfoFromUri( string uri )
{
   u.str_argcheck.NE( uri, nameof(uri) );
   return u.platform.IsWindowsOS ?
      new ProcessStartInfo( uri ){
         UseShellExecute = true,
         Verb = "open" } :
      u.platform.IsOSX ? new ProcessStartInfo( "open", uri ) :
      u.platform.IsUnixLikeOS ? new ProcessStartInfo( "xdg-open", uri )
      : throw new PlatformNotSupportedException();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // shell

} // user_rtx (.wasm)
